[fpc-pascal] math round vs banker's round

Sven Barth pascaldragon at googlemail.com
Wed Aug 14 10:27:57 CEST 2013


Am 14.08.2013 10:11, schrieb Jonas Maebe:
>
> On 14 Aug 2013, at 09:38, Sven Barth wrote:
>
>> - 0.5 does not always have a direct representation as a floating 
>> point value and thus internally it might be 0.4999999 or something 
>> like that and thus it will be rounded to 0.4 (see 
>> alsohttp://bugs.freepascal.org/view.php?id=24374)
>
> 0.5 is one of the values that can always be represented exactly. The 
> fractional part of IEEE 754 floating point numbers is represented as 
> sums of negative powers of 2, i.e. 0.5, 0.25, etc.
>
It should have been "x.5" instead of "0.5" :)

What's your opinion regarding the point that the compiler does not 
handle the rounding mode when "Round" is inlined for constants?

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130814/28d74ef4/attachment.html>


More information about the fpc-pascal mailing list