← index #11284PR #16480
Likely Duplicate · high · value 0.331
QUERY · ISSUE

f-string thousands separator doesn't work with floats

openby BrianPughopened 2023-04-17updated 2023-05-04
bugpy-core

On v1.19.1, f-string thousands separator doesn't work with floats. Tested on both unix and rp2040:

Demo code:

foo_int = 123456
foo_float = 1234.56789
print(f"{foo_int:,}   {foo_float:,}")

CPython (correct):

123,456   1,234.56789

MicroPython (incorrect):

123,456   1234.57
CANDIDATE · PULL REQUEST

f-string thousands separator for float

openby ludollaooopened 2024-12-24updated 2025-01-28
py-core

Summary

Closes #11284
thousand separator was not implemented for floating point number

Testing

test the thousand separator for different float
test that the rounding up with the thousand separator (esp : 9,999.99 rounded to 10,000.0)

couldn't test that no buffer overflow occurs when using the thousand separator

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied