Skip to content

Feature request: Add precision option to keep trailing zeros #14

@nevermille

Description

@nevermille

So today, Precision::Decimals works like this:

# use numfmt::*;
let mut f = Formatter::new() // start with blank representation
    .separator(',').unwrap()
    .prefix("AU$").unwrap()
    .precision(Precision::Decimals(2));

assert_eq!(f.fmt(12345678900.0), "AU$12,345,678,900.0");

But sometimes (especially whit money), trailing zeros are needed. So it would be great if we had something like this:

# use numfmt::*;
let mut f = Formatter::new() // start with blank representation
    .separator(',').unwrap()
    .prefix("AU$").unwrap()
    .precision(Precision::Always(2));

assert_eq!(f.fmt(12345678900.0), "AU$12,345,678,900.00");

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