digitalmars.D - std.math: FloatingPointControl option to round to nearest + tie away from zero
- Shriramana Sharma (9/9) Dec 10 2015 https://en.wikipedia.org/wiki/IEEE_floating_point#Roundings_to_nearest s...
- Matthias Bentrup (7/13) Dec 11 2015 Those are basically the rounding modes supported by the FPUs in
https://en.wikipedia.org/wiki/IEEE_floating_point#Roundings_to_nearest says that IEEE 754 provides two options for rounding to nearest: ties to even and ties away from zero. However, under https://github.com/D-Programming-Language/phobos/blob/mas er/std/math.d#L4539 we have only one roundToNearest which, I presume, ties to even. Is there a difficulty in providing the option for tieing away from zero? Thanks. --
Dec 10 2015
On Friday, 11 December 2015 at 05:25:03 UTC, Shriramana Sharma wrote:https://en.wikipedia.org/wiki/IEEE_floating_point#Roundings_to_nearest says that IEEE 754 provides two options for rounding to nearest: ties to even and ties away from zero. However, under https://github.com/D-Programming-Language/phobos/blob/master/std/math.d#L4539 we have only one roundToNearest which, I presume, ties to even. Is there a difficulty in providing the option for tieing away from zero? Thanks.Those are basically the rounding modes supported by the FPUs in hardware. Any other rounding modes would have to be emulated in software, which would require the compiler to generate completely different code instead of just changing a few bits in an FPU control register.
Dec 11 2015