Skip to content

Formatting of 0e15 is 0000000000000000, not 0 as expected #144

@drinkcat

Description

@drinkcat

Formatting 0e15 leads to 0000000000000000, not 0 as expected.

I assume there is something wrong in the logic to add trailing zeros when there isn't a significant digit.

Trying to have a look.


Adding this test case fails:

        mod dec_0e15 {
            use super::*;

            fn test_input() -> BigDecimal {
                "0e15".parse().unwrap()
            }

            impl_case!(fmt_default:        "{}" => "0");
            impl_case!(fmt_d0:          "{:.0}" => "0");
            impl_case!(fmt_d1:          "{:.1}" => "0.0");
        }
---- impl_fmt::test::fmt_options::dec_0e15::fmt_d0 stdout ----

thread 'impl_fmt::test::fmt_options::dec_0e15::fmt_d0' panicked at src/impl_fmt.rs:1193:13:
assertion `left == right` failed
  left: "0000000000000000"
 right: "0"

---- impl_fmt::test::fmt_options::dec_0e15::fmt_d1 stdout ----

thread 'impl_fmt::test::fmt_options::dec_0e15::fmt_d1' panicked at src/impl_fmt.rs:1194:13:
assertion `left == right` failed
  left: "0000000000000000.0"
 right: "0.0"

---- impl_fmt::test::fmt_options::dec_0e15::fmt_default stdout ----

thread 'impl_fmt::test::fmt_options::dec_0e15::fmt_default' panicked at src/impl_fmt.rs:1192:13:
assertion `left == right` failed
  left: "0000000000000000"
 right: "0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions