format %A garbles negative, padded and infinite values
format %A -1.5 ;# -xX1.8p+0 format %+A 1.0 ;# +xX1p+0 format %10A 1.5 ;# x0X1.8p+0 format %A Inf ;# IxF
Only plain positive values come out right (0x1.8p+0). The code came with %a/%A in [5cfe15b5d6].
36bdf0d513Ticket [dbf9884c56] socket-14.19 and scan-15.1 fail on illumos status still Closed with 4 other changes ticket2026-10-18 20:44:0125cc9dd9b0Follow-up to [2dff98e079]: Fix testcases on MSVCRT check-in2026-10-18 20:09:53185825858eFollow-up to [2dff98e079]: Fix testcases on MSVCRT check-in2026-10-18 20:09:114b524ff3baPending ticket [2dff98e079]: format %A garbles negative, padded and infinite values plus 4 other changes ticket2026-10-18 08:53:2806f25062c2Fix [2dff98e079]: format %A garbles negative, padded and infinite values check-in2026-10-17 07:22:409336b96c43Fix [2dff98e079]: format %A garbles negative, padded and infinite values check-in2026-10-17 07:20:125f07f3abbaFix [2dff98e079]: format %A garbled negative, padded and infinite values. Lowercase the "0X" prefix and the "P" exponent marker where they are, instead of assuming that the result starts with "0X". check-in2026-10-16 22:17:42
Proposed fix in branch format-A-prefix: lowercase the "0X" prefix and the "P" exponent marker where they are, which is after the padding and the sign, and leave INF alone. Test format-19.5.
+1
Please go ahead
Merged into main in [9336b96c43] and into 9.0 in [06f25062c2].
Just one thing left to fix. With msvcrt (not ucrt):
==== format-19.5 %A with sign, padding and Inf, bug [2dff98e079] FAILED ==== Contents of test case:# explicit precision: without it MSVC prints all 13 hex digits list [format %.1A 1.5] [format %.1A -1.5] [format %+.0A 1.0] [format "% .0A" 1.0] [format %10.1A 1.5] [format %-10.0A| -2.0] [format %A Inf] [format %A -Inf]---- Result was: 0x1.8p+0 -0x1.8p+0 +0x1p+0 { 0x1p+0} { 0x1.8p+0} {-0x1p+1 |} 0x1.#INF00p+0 -0x1.#INF00p+0 ---- Result should have been (exact matching): 0x1.8p+0 -0x1.8p+0 +0x1p+0 { 0x1p+0} { 0x1.8p+0} {-0x1p+1 |} INF -INF ==== format-19.5 FAILED
Matching with -glob would be easiest: If it contains 'INF' that should be OK
My proposal [6715b0e7eddf95f|here] (unless someone has a better idea)
My proposal [6715b0e7eddf95f|here] (unless someone has a better idea)
My proposal [here] (unless someone has a better idea)
Another option, done in [f5bb9702a9]: format infinities ourselves instead of passing them to the C library, as Python does. msvcrt gets them wrong for all float conversions, not only %A (1.#INF00e+000, 1.#INF even for %G). Now they are inf or INF (for %A, %E, %G) with the sign flags, padded with spaces, as C99 specifies; the output on glibc and ucrt does not change. format-19.5 is exact again, new test format-19.6. Tested with a mingw msvcrt build on Windows 11: format.test passes, and fails without this change. NaN cannot get there, it is rejected earlier.
Agreed! Follow-up patch now merged too.
Thanks!
The infinity part of the follow-up [185825858e] was backported to 8.6 in [326e1bf923] for [40f315bc23]. 8.6 has no %a/%A.