Commit 555ee9d
committed
Do not emit a leading zero in floatToGoString exponents >= 10
floatToGoString reproduces Go's strconv.FormatFloat(f, 'g', -1, 64),
which pads a float's exponent to a minimum of two digits. The exponent
was formatted as 'e+0{dot - 1}', which hard-codes a single leading zero
and only produces the right width while dot - 1 is a single digit. Once
the exponent reaches two digits (values >= 1e10, whose repr is still
plain decimal) it over-pads, e.g. 1e10 became '1e+010' instead of Go's
'1e+10'. That affects any emitted sample value or le/quantile bucket
boundary at or above 1e10.
Use '{dot - 1:02d}' so the exponent is zero-padded to a minimum of two
digits and not beyond, matching Go.
Add tests/test_utils.py covering both the previously-correct single-digit
exponents and the two-digit exponents that regressed.
Signed-off-by: Sean Kim <skim8705@gmail.com>1 parent a96f6f4 commit 555ee9d
2 files changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments