SourceForge has been redesigned. Learn more.

#1427 ANSI mode printf("%a", ...) is incorrect


printf("%a", ...) produces incorrect output for some numbers.

In particular, it seems to be broken for numbers smaller than the smallest normalized single-precision floating-point number.

I originally saw this using MinGW runtime 3.15.2 and 3.18.0 has the same problem.

Build the test case using gcc -Wall -std=c99 printf-a-bug.c.
When run, it will print:
0x1p-125 2.35099e-038
0x0p-126 1.17549e-038
where the second line _should_ read 0x1p-126 (or equivalent).


  • Keith Marshall

    Keith Marshall - 2010-06-12
    • assigned_to: nobody --> keithmarshall
  • Keith Marshall

    Keith Marshall - 2012-03-07
    • status: open --> pending-fixed
  • Keith Marshall

    Keith Marshall - 2012-03-07

    Is this still an issue? I believe it has been fixed; with my current libmingwex.a build I see:

    $ mingw32-gcc -std=c99 ~/downloads/printf-a-bug.c
    $ ./a.exe
    0x8p-128 2.35099e-038
    0x8p-129 1.17549e-038

    Okay to close?

  • Gustav Hållberg

    Sounds good :)

  • Gustav Hållberg

    • status: pending-fixed --> open-fixed
  • Keith Marshall

    Keith Marshall - 2012-03-07
    • status: open-fixed --> closed-fixed
  • Keith Marshall

    Keith Marshall - 2012-03-07

    Okay, thanks. I've retested with a copy of libmingwex.a from downloaded mingwrt-3.20, which already appears to include the fix. Closing as fixed.


Log in to post a comment.