You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Format specifies don't seem to be fully implemented #2582
Supporting all format specifiers is quite complicated and we're doing it bit by bit 😸 You can check which formats are supported in the String tests. In one of the latest releases we added support for thousand separators with the #,## pattern:
Thanks for the report! I investigated the current status of the N format specifier and found that it has been partially fixed over time, but there's still a bug for the N0 case.
Current status:
N / N2 (default precision 2): Works correctly — (1000).ToString("N2") → "1,000.00" ✓
Root cause in src/fable-library-ts/String.ts: the N format case unconditionally appends "." + decimal, even when precision = 0. The F format has the correct pattern (guards with if (precision > 0)), but N was missing this guard.
I've submitted a fix in PR #4422 (if not yet visible, check the linked branch) that mirrors the F format's approach:
Activity
alfonsogarciacaro commentedon Jan 7, 2022
Supporting all format specifiers is quite complicated and we're doing it bit by bit 😸 You can check which formats are supported in the String tests. In one of the latest releases we added support for thousand separators with the
#,##pattern:Fable/tests/Main/StringTests.fs
Lines 352 to 360 in b897166
If you need something in particular, could you please provide a test like the linked one with the expected results in .NET. Thank you very much!
Fix N format specifier producing trailing dot when precision is 0
github-actions commentedon Mar 19, 2026
🤖 This is an automated response from Repo Assist.
Thanks for the report! I investigated the current status of the
Nformat specifier and found that it has been partially fixed over time, but there's still a bug for theN0case.Current status:
N/N2(default precision 2): Works correctly —(1000).ToString("N2")→"1,000.00"✓N0(zero decimal places): Broken —(1000).ToString("N0")→"1,000."(trailing dot instead of"1,000")Root cause in
src/fable-library-ts/String.ts: theNformat case unconditionally appends"." + decimal, even whenprecision = 0. TheFformat has the correct pattern (guards withif (precision > 0)), butNwas missing this guard.I've submitted a fix in PR #4422 (if not yet visible, check the linked branch) that mirrors the
Fformat's approach:Note: the same trailing-dot bug exists for
P0(percentage) andC0(currency) format specifiers — those could be fixed in a follow-up PR if needed.Fix N format specifier producing trailing dot when precision is 0
Add regression tests for N0, C0, P0 format specifiers