in reply to Re: Decimal precision issue: Windows vs. Unix
in thread Decimal precision issue: Windows vs. Unix
IEEE 754 requires correct rounding for numbers of this sort of size.
IEEE 754 has four rounding modes(bottom of the page.
Rounds to the nearest value, except for 5 which is equidistant, in which case it rounds to the nearest even digit.
Next higher
Next lower.
Truncate.
All are valid.
The MS CRT provides _control87 and varients to allow the user to choose which mode they require. With the default being nearest.
In the case of -95.24436542871095 (the fullest precision available from a 8-byte float), with the last digit (5) being equidistant from ...09 and ...10, it rounds to the even value. Per the spec.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Decimal precision issue: Windows vs. Unix
by gone2015 (Deacon) on Jan 11, 2009 at 00:25 UTC |