POV-Ray : Newsgroups : povray.newusers : rounding Server Time
28 Jul 2024 22:19:22 EDT (-0400)
  rounding (Message 21 to 26 of 26)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: andrel
Subject: Re: rounding
Date: 29 Jun 2008 17:58:50
Message: <486805CE.2020701@hotmail.com>
alphaQuad wrote:
> didnt read it. 
read what?

> I've seen less complex functions work and not work neagtive-wise,
> depending on the sytem. handle negs, int() instead of floor() in POV should
> solve the neg issue
There is no "neg issue". People have different expectation on what e.g. 
floor() should do for negative numbers. It is more or less arbitrary, 
but it has to be defined. I agree that round() could be added as a 
function in POV4. Preferably not as a macro. Macro's tend to be written 
again and again. That is a waste of time and possibly dangerous as well 
if someone implements it subtly different from somebody else.


Post a reply to this message

From: Warp
Subject: Re: rounding
Date: 29 Jun 2008 18:03:02
Message: <48680696@news.povray.org>
andrel <a_l### [at] hotmailcom> wrote:
> People have different expectation on what e.g. 
> floor() should do for negative numbers.

  AFAIK the floor() function is universally defined to round downwards,
as the name implies. In other words, the return value is always smaller
or equal to the parameter.

> I agree that round() could be added as a function in POV4.

  Why? floor(value+.5) does the same thing.

-- 
                                                          - Warp


Post a reply to this message

From: andrel
Subject: Re: rounding
Date: 29 Jun 2008 18:31:28
Message: <48680D75.9030509@hotmail.com>
Warp wrote:
> andrel <a_l### [at] hotmailcom> wrote:
>> People have different expectation on what e.g. 
>> floor() should do for negative numbers.
> 
>   AFAIK the floor() function is universally defined to round downwards,
> as the name implies. In other words, the return value is always smaller
> or equal to the parameter.
yes (except perhaps on very old equipment that had a sign bit and not 
2s-complement), but that does not stop people from expecting that
floor(-x+.5)==-floor(x+.5) everywhere.
I was talking about expectations not definitions. (ok, 'would' in stead 
of 'should' would (should?) have been better)
> 
>> I agree that round() could be added as a function in POV4.
> 
>   Why? floor(value+.5) does the same thing.
> 
no it doesn't, that was the whole point. In some cases people want a 
function that round halves away from zero. round(-3.5)=-4


Post a reply to this message

From: Warp
Subject: Re: rounding
Date: 29 Jun 2008 18:54:59
Message: <486812c3@news.povray.org>
andrel <a_l### [at] hotmailcom> wrote:
> >   Why? floor(value+.5) does the same thing.
> > 
> no it doesn't, that was the whole point. In some cases people want a 
> function that round halves away from zero. round(-3.5)=-4

  Why would anyone want to round halves away from zero? And if someone
*really* wants that, he can make his own function which does that. The
rest can use either floor(value+.5) or ceil(value-.5), whichever they
prefer.

-- 
                                                          - Warp


Post a reply to this message

From: Alain
Subject: Re: rounding
Date: 30 Jun 2008 15:58:37
Message: <48693aed$1@news.povray.org>
andrel nous illumina en ce 2008-06-29 18:32 -->

> yes (except perhaps on very old equipment that had a sign bit and not 
> 2s-complement), but that does not stop people from expecting that
> floor(-x+.5)==-floor(x+.5) everywhere.

That expectation come from the fact that many peoples considere 0 to be smaler 
than -1, whitch is false. Many peoples have the tendency of ignoring the sign 
when quickly comparing values, only concidering the absolute value instead of 
the real one.


-- 
Alain
-------------------------------------------------
A short cut is the longest distance between two points.


Post a reply to this message

From: andrel
Subject: Re: rounding
Date: 3 Jul 2008 18:57:51
Message: <486D59A5.4050308@hotmail.com>
Alain wrote:
> andrel nous illumina en ce 2008-06-29 18:32 -->
> 
>> yes (except perhaps on very old equipment that had a sign bit and not 
>> 2s-complement), but that does not stop people from expecting that
>> floor(-x+.5)==-floor(x+.5) everywhere.
> 
> That expectation come from the fact that many peoples considere 0 to be 
> smaler than -1, whitch is false. Many peoples have the tendency of 
> ignoring the sign when quickly comparing values, only concidering the 
> absolute value instead of the real one.
> 
I don't think so. Anyway, this example did not express what I meant :(

BTW one reason for thinking that there may be a reason why people expect 
round(-3.5) to be -4 is that Matlab thinks so too.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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