Floating point rounding modes: we should restrict them slightly

Jimbob jim at bob.com
Thu Sep 10 07:59:51 PDT 2009


"#ponce" <aliloko at gmail.com> wrote in message 
news:h8adr2$23p3$1 at digitalmars.com...
> Why not imposing a rounding mode (ex :  toward minus infinity) ?
> And then disallowing to change it in assembly.
>
> I mean, you can still do :
>  round(x) as floor(x + 0.5L)
>  ceil(x) as floor(x + 1.0L)
>
> Iit would cost some precision with large floating-point number, but not 
> much since rounding such large numbers has few meaning.
>
> It would clear up the rounding-mode mess a bit.

There's more to rounding modes than just converting / rounding to integer. 
Rounding affects all arithmetic operations, and whether an expresion 
evaluates to 0.97999 or .97998 can be important in some cases.









More information about the Digitalmars-d mailing list