POV-Ray : Newsgroups : povray.general : Function: Making negative numbers positive : Re: Function: Making negative numbers positive Server Time
26 Jun 2024 13:50:40 EDT (-0400)
  Re: Function: Making negative numbers positive  
From: Alain
Date: 27 Nov 2015 14:26:01
Message: <5658ae49$1@news.povray.org>
Le 15-11-27 11:20, Todd Carnes a écrit :
> On 2015-11-27 02:45, clipka wrote:
>> That's only true if the number in question is known to be negative.
>>
>
> I know, but that was what the OP asked for.
>
>> In that case, however, it is easier and more efficient to just use the
>> unary minus operator:
>>
>> #declare PositiveNumber = -NegativeNumber;
>
> That works too, but then it's really just masking the fact that you are
> doing what I said... i.e. multiplying by -1.
>
> Todd
>

It's always safer to assume that the value in question *may* be negative 
as well as positive.
You want the result to be *always* positive indepentently if it's 
original sign.



Alain


Post a reply to this message

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