Files
AnyPS5/docs/dev/debt/changes/docs-libc-printf-float-console-1160.md
DerKarussellbremserandClaude Fable 5.2 3066e4a9a7 fix(libc): generate printf's decimal digits as the bundled libc.prx does
%e, %f and %g printed exact digits cut at a fitted position. The
libc.prx bundled with PPSA10122 01.101.000 scales the value by a power
of ten in three-part arithmetic and takes eight digits at a time, which
is where the console's outputs that end one unit lower come from. The
four such cases measured on firmware 11.60 are now reproduced.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
2026-11-19 04:07:25 +01:00

2.0 KiB

libc

change [%a and %A]

  • %a and %A (libc) format a finite double as the libc.prx that titles ship does, instead of through the host: a subnormal is normalised (0x1p-1074), a shorter precision rounds half up on the dropped hexadecimal digits and a carry stays in the leading digit (%.3a of 0x0.fffffffffffffp-1022 is 0x2.000p-1023), and - overrides 0. Checked against the copies of PPSA13934, PPSA07923 and PPSA05916 on 7 million random formats, and measured on a console only in 28 cases (1, 0.5, 1.99951171875, 3.5, DBL_MAX, DBL_MIN, 1 - 2^-53 with %a, %A, %.3a and %-010.3a), where it gave the same text, as it did on a PS5 payload process (firmware 11.60) in 7 more cases, among them 5e-324 and -0.0; titles not measured. A long double is normalised the same way, with 16 hexadecimal digits (0x1.999999999999999ap-4 for 0.1L). Infinities still go to the host; NaN keeps its sign and flags through the formatter on current main.

change [%e, %f and %g]

  • %e, %f and %g (libc) generate the decimal digits of a finite double or long double with the method of the libc.prx bundled with PPSA10122 01.101.000 (0x1700): the magnitude in three 32-bit parts is scaled by a power of ten in that arithmetic, at most 22 digits are taken eight at a time and rounded half up (%f of 1e22 is 9999999999999999999999.000000). The digits depend on the caller's x87 precision and rounding mode, as the module's do. All 239 double texts that a PS5 payload process printed on firmware 11.60 are reproduced, and 200,000 values with random flags, widths and precisions in each of six x87 modes give the module's text, run natively on Windows; long double and a title process are not measured on a console. A host whose long double is not the x87 format keeps the earlier method (exact digits down to position 4 * floor(k / 4) - 20). The wide printf family uses the same digits.