Skip to content

Formatting a negative currency with rounding results in an invalid string #777

Open
@Vesuri

Description

@Vesuri

When using the format string "$0,0.00" formatting a value in the range -0.005 <= value < 0 results in the string 0$.00 instead of $0.00:

>> numeral(5).format("$0,0.00");
"$5.00"
>> numeral(0.05).format("$0,0.00");
"$0.05"
>> numeral(0.005).format("$0,0.00");
"$0.01"
>> numeral(0.004).format("$0,0.00");
"$0.00"
>> numeral(-0.000).format("$0,0.00");
"$0.00"
>> numeral(-0.001).format("$0,0.00");
"0$.00"
>> numeral(-0.005).format("$0,0.00");
"0$.00"
>> numeral(-0.006).format("$0,0.00");
"-$0.01"

Numeral version 2.0.6. Tested with Firefox version 105.0.1 and Chrome version 105.0.5195.125.

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