Stop to! rounding?

Jonathan M Davis jmdavisProg at gmx.com
Tue Jul 2 21:31:53 PDT 2013


On Wednesday, July 03, 2013 06:23:12 Josh wrote:
> writeln(to!double("151.42499"));    //prints 151.425
> 
> Is there any way to stop this rounding?

No. double can't hold the value 151.42499. There are _tons_ of values that it 
can't hold exactly. The same goes for float and real. Floating point values are 
rounded all the time. Note that

    double d = 151.42499;
    writeln(d);

prints exactly the same thing as your example.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list