[Issue 9889] Incorrect rounding on floating value formatting
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Sat Jan 24 06:44:47 PST 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=9889
AndyC <andy at squeakycode.net> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andy at squeakycode.net
                 OS|Windows                     |Linux
--- Comment #1 from AndyC <andy at squeakycode.net> ---
Tested on DMD v2.066.1, this runs fine.
import std.string;
void main()
{
    assert(format("%.1f", 0.09) == "0.1"); // Failed, formatted as "0.0"
    assert(format("%.1f", -0.09) == "-0.1"); // Failed, formatted as "-0.0"
    assert(format("%.1f", 0.095) == "0.1"); // OK
    assert(format("%.1f", -0.095) == "-0.1"); // OK
    assert(format("%.1f", 0.094) == "0.1"); // Failed, formatted as "0.0"
    assert(format("%.1f", -0.094) == "-0.1"); // Failed, formatted as "-0.0"
}
Report was on windows, I tested in on linux, hopefully format() isnt os
specific.
Report mentions std.format.formatValue but doesnt test it.
--
    
    
More information about the Digitalmars-d-bugs
mailing list