Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion common/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,13 @@ impl FormatSpec {
const fn get_separator_interval(&self) -> usize {
match self.format_type {
Some(FormatType::Binary | FormatType::Octal | FormatType::Hex(_)) => 4,
Some(FormatType::Decimal | FormatType::Number(_) | FormatType::FixedPoint(_)) => 3,
Some(
FormatType::Decimal
| FormatType::FixedPoint(_)
| FormatType::GeneralFormat(_)
| FormatType::Exponent(_)
| FormatType::Percentage,
) => 3,
None => 3,
_ => panic!("Separators only valid for numbers!"),
}
Expand Down
5 changes: 5 additions & 0 deletions extra_tests/snippets/builtin_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def test_zero_padding():
assert f"{12345.6 + 7890.1j:,}" == "(12,345.6+7,890.1j)"
assert f"{12345.6 + 7890.1j:_.3f}" == "12_345.600+7_890.100j"
assert f"{12345.6 + 7890.1j:>+30,f}" == " +12,345.600000+7,890.100000j"
assert f"{123456:,g}" == "123,456"
assert f"{123456:,G}" == "123,456"
assert f"{123456:,e}" == "1.234560e+05"
assert f"{123456:,E}" == "1.234560E+05"
assert f"{123456:,%}" == "12,345,600.000000%"

# test issue 4558
x = 123456789012345678901234567890
Expand Down
Loading