std.math: FloatingPointControl option to round to nearest + tie away from zero

Matthias Bentrup via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 11 01:13:22 PST 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.



More information about the Digitalmars-d mailing list