On 11 Jul 2011, at 08:23, Riccardo Mottola wrote:

> To my knowledge, rint() doesn't do any advanced rounding. It doesn't try to 
> minimize the error by rounding odd numbers down and even up or something like 
> that, it uses a standard round direction.  16.5 will become 17 as 17.5 will 
> become 18. That is, the round error hasn't a zero expected value.
> 
> 
> To prove that, I executed a loop in 0.1 steps and printed out the results:
> 
> long float: 16.000000, rounded: 16.000000
> long float: 16.100000, rounded: 16.000000
> long float: 16.200000, rounded: 16.000000
> long float: 16.300000, rounded: 16.000000
> long float: 16.400000, rounded: 16.000000
> long float: 16.500000, rounded: 17.000000
> long float: 16.600000, rounded: 17.000000
> long float: 16.700000, rounded: 17.000000
> long float: 16.800000, rounded: 17.000000
> long float: 16.900000, rounded: 17.000000
> long float: 17.000000, rounded: 17.000000
> long float: 17.100000, rounded: 17.000000
> long float: 17.200000, rounded: 17.000000
> long float: 17.300000, rounded: 17.000000
> long float: 17.400000, rounded: 17.000000
> long float: 17.500000, rounded: 18.000000
> long float: 17.600000, rounded: 18.000000
> long float: 17.700000, rounded: 18.000000
> long float: 17.800000, rounded: 18.000000
> long float: 17.900000, rounded: 18.000000

Note that with steps of 0.1 you will not see the round-to-nearest-even 
behavior, as it will not trip on the exact halfway points due to rounding 
errors. Increment by 0.25 to check whether round-to-nearest-even is in action.

Tim


_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to