POV-Ray : Newsgroups : povray.off-topic : Unexpected : Re: Unexpected Server Time
28 Jul 2024 16:24:31 EDT (-0400)
  Re: Unexpected  
From: clipka
Date: 17 Aug 2013 13:58:36
Message: <520fb9cc$1@news.povray.org>
Am 17.08.2013 11:20, schrieb Orchid Win7 v1:

>    int abs(int input)
>    {

...

> (My boss has a standard set of ways to implement abs(). They include:
>
> * if (x < 0) return 0-x; else return x;
>
> * return sqrt(x*x); // Evil.
>
> * return str.Remove('-'); // String munging. Very evil!
>
> * if (x < 0) return x ^ 0x8000; else return x; // DOESN'T ACTUALLY WORK!
>
> I'm sure there must be more evil ways of doing this...)

He should also be prepared for

     return Math.Abs(input);

possibly with an added comment to the effect that the abs(int) function 
should be refactored away at the earliest possible opportunity ;-)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.