Fix: Correct precision calculation for floating point formatting (#2657)

* Fix: Correct precision calculation for floating point formatting

---------

Signed-off-by: Manuel Barrio Linares <mbarriolinares@gmail.com>
Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Manu Linares
2025-12-19 11:51:42 -03:00
committed by GitHub
parent 29bcd2c96e
commit dec49b05b8
3 changed files with 29 additions and 1 deletions

View File

@@ -364,7 +364,10 @@ fn usz? Formatter.floatformat(&self, FloatFormatting formatting, double y) @priv
}
// Perform rounding: j is precision after the radix (possibly neg)
int j = (int)(p - (isz)(formatting == FLOAT ? 0 : e - (int)(formatting == ADAPTIVE && p)));
int j = (int)p;
if (formatting != FLOAT) j -= e;
if (formatting == ADAPTIVE && p != 0) j -= 1;
if (j < 9 * (z - r - 1))
{
uint x;