POV-Ray : Newsgroups : povray.documentation.inbuilt : revisiting rand(...) : Re: revisiting rand(...) Server Time
25 Oct 2021 02:32:03 EDT (-0400)
  Re: revisiting rand(...)  
From: clipka
Date: 19 Jul 2018 11:58:56
Message: <5b50b540$1@news.povray.org>
Am 19.07.2018 um 03:38 schrieb Alain:

>> I did find the topic of rounding to be more complex than my initial naive
>> concept.  There are different ways to do it, and it would be useful and
>> instructive to see examples of code that performed all the different
>> variations.
> 
> Mostly, there are 3 ways : Round down, or truncate, round to the closest
> and round up.

Actually there are a few more commonly used:

- Round towards negative infinity (round down)
- Round towards positive infinity (round up)
- Round towards zero (truncate)
- Round towards infinity of same sign
- Round to nearest ("proper" rounding)

In the latter mode, there is again a host of ways to handle values smack
in the middle between the nearest representable numbers (think 0.5):

- Round towards negative infinity (round down)
- Round towards positive infinity (round up)
- Round towards zero (truncate)
- Round towards infinity of same sign
- Round up if even, down if odd
- Round down if even, up if odd


Post a reply to this message

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