Thread overview
[Issue 9889] Incorrect rounding on floating value formatting
Jan 24, 2015
AndyC
Jan 24, 2015
yebblies
Jan 25, 2015
Denis Shelomovskij
Jan 25, 2015
yebblies
Jan 20, 2021
Dlang Bot
Feb 13, 2021
Walter Bright
Feb 15, 2021
Dlang Bot
January 24, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

AndyC <andy@squeakycode.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andy@squeakycode.net
                 OS|Windows                     |Linux

--- Comment #1 from AndyC <andy@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.

--
January 24, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei@erdani.com
         Resolution|---                         |FIXED

--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> ---
Closing preemptively according to http://forum.dlang.org/thread/fsmjexsfxtqveqffiemc@forum.dlang.org#post-ybwwdcpzianfozqcflcv:40forum.dlang.org. Please reopen if necessary, thanks.

--
January 24, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |yebblies@gmail.com
         Resolution|FIXED                       |---
                 OS|Linux                       |Windows

--- Comment #3 from yebblies <yebblies@gmail.com> ---
As the original comment states, this is specific to snn.lib (digital mars' c runtime) and therefore win32.

--
January 24, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

--- Comment #4 from Andrei Alexandrescu <andrei@erdani.com> ---
Thanks @yebblies!

--
January 25, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

--- Comment #5 from Denis Shelomovskij <verylonglogin.reg@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #2)
> Closing preemptively according to http://forum.dlang.org/thread/fsmjexsfxtqveqffiemc@forum.dlang.org#post- ybwwdcpzianfozqcflcv:40forum.dlang.org. Please reopen if necessary, thanks.

Wat has just happened here?

There was a Windows-specific bug report. A person who isn't fimilar with Phobos and lokks like a newbie (not his fault by the way) tested it on Linux, said "testcase works" and changed OS to Linux, also proving the fact he has no idea how does formatting work by writing "format() isnt os specific" and "Report mentions std.format.formatValue but doesnt test it". And based on this the issue was closed by a Phobos developer.

So I'd like to ask Phobos devs: please, if your are tired and out of time, don't do thoughtless actions. In case something probably can be easily closed/fixed etc. please ask issue reporter or another person who has more time to induct because such actions in the worst case may remain unnoticed. Thanks.

--
January 25, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

--- Comment #6 from yebblies <yebblies@gmail.com> ---
(In reply to Denis Shelomovskij from comment #5)
> 
> Wat has just happened here?
> 
> There was a Windows-specific bug report. A person who isn't fimilar with Phobos and lokks like a newbie (not his fault by the way) tested it on Linux, said "testcase works" and changed OS to Linux, also proving the fact he has no idea how does formatting work by writing "format() isnt os specific" and "Report mentions std.format.formatValue but doesnt test it". And based on this the issue was closed by a Phobos developer.
> 
> So I'd like to ask Phobos devs: please, if your are tired and out of time, don't do thoughtless actions. In case something probably can be easily closed/fixed etc. please ask issue reporter or another person who has more time to induct because such actions in the worst case may remain unnoticed. Thanks.

The original reporter is CC'd when an issue is closed or updated, so mistakes can easily be corrected.  It's not a big deal, just a mistake.

--
January 26, 2015
https://issues.dlang.org/show_bug.cgi?id=9889

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com
           Hardware|All                         |x86

--- Comment #7 from Steven Schveighoffer <schveiguy@yahoo.com> ---
Adjusting arch to be X86 only according to Daniel's comment.

One thing I would mention -- it's not readily apparent that any of the fields above have changed since the original report, the change is logged but you have to look at bug history to see the change. Please avoid changing them unless you are certain that the change is correct. AndyC, I appreciate you combing through old bugs, so please keep going!

--
January 20, 2021
https://issues.dlang.org/show_bug.cgi?id=9889

--- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> ---
@berni44 created dlang/phobos pull request #7757 "Partial replace call to snprintf for formating floatingpoint numbers for %f and %F" fixing this issue:

- Fix Issue 9889 - Incorrect rounding on floating value formatting

https://github.com/dlang/phobos/pull/7757

--
February 13, 2021
https://issues.dlang.org/show_bug.cgi?id=9889

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=3248

--
February 15, 2021
https://issues.dlang.org/show_bug.cgi?id=9889

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #7757 "Partial replace call to snprintf for formating floatingpoint numbers for %f and %F" was merged into master:

- 3767b6c06af271f6aa72cbfbc7a210e582401447 by Bernhard Seckinger:
  Fix Issue 9889 - Incorrect rounding on floating value formatting

https://github.com/dlang/phobos/pull/7757

--