Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Vesuri opened this issue Oct 4, 2022 · 2 comments
Open

Comments

@Vesuri
Copy link

Vesuri commented Oct 4, 2022

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.

@fredrivett
Copy link

fredrivett commented Jan 31, 2023

I'm also seeing the strange behaviour (also on numeral 2.0.6):

>> numeral(-0.005).format("$0,0.00");
"0$.00"

EDIT: FWIW it seems numbro (a more recently maintained fork of this repo) doesn't have this issue for me.

amirmm03 added a commit to amirmm03/Numeral-js that referenced this issue Jul 4, 2023
@amirmm03 amirmm03 mentioned this issue Jul 4, 2023
@zahidmak24
Copy link

Is there a plan to address this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants