Open ghost opened 9 years ago
The first problem was defaulting to zero (0) if the value was falsy in the unformat function:
number = value || 0;
If the number was -0 it was set to 0.
-0
0
This default value for number was moved to after the check of being a number or not to prevent this from happening.
The second issue is determining negative numbers in JavaScript:
-0 < 0 false
So a new function isNegative was added to work with negative zeros as well.
isNegative
Finally, a new test case was added that demonstrates that the new behavior works as intended.
Let me know if this needs any more work before it can be merged in and I'll be happy to make any changes. Thanks.
The first problem was defaulting to zero (0) if the value was falsy in the unformat function:
If the number was
-0
it was set to0
.This default value for number was moved to after the check of being a number or not to prevent this from happening.
The second issue is determining negative numbers in JavaScript:
So a new function
isNegative
was added to work with negative zeros as well.Finally, a new test case was added that demonstrates that the new behavior works as intended.