jart / cosmopolitan

build-once run-anywhere c library
ISC License
18.44k stars 637 forks source link

Partially fix printf hex float numbers/%a rounding #1286

Closed GabrielRavier closed 2 months ago

GabrielRavier commented 2 months ago

Hexadecimal printing of floating-point numbers on cosmopolitan (that is, using the a conversion specifier) currently does not correctly round the result in any rounding mode except for the default one (i.e. FE_NEAREST)

This commit fixes this, and adds tests for the change (note that there's still some rounding issues with the a conversion specifier in general in relatively rare cases (that is, without non-default rounding modes), but this author gave up on fixing them after they tried to read the floating point formatting code, and wounded up almost more confused than before).

jart commented 2 months ago

Commit message edited to communicate the improvement rather than the problem.