diff --git a/common/src/format.rs b/common/src/format.rs index 120eefcbc3..447ae575f4 100644 --- a/common/src/format.rs +++ b/common/src/format.rs @@ -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!"), } diff --git a/extra_tests/snippets/builtin_format.py b/extra_tests/snippets/builtin_format.py index ac7afb769a..a5edcc8952 100644 --- a/extra_tests/snippets/builtin_format.py +++ b/extra_tests/snippets/builtin_format.py @@ -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