You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when bytes is zero or negative, the original number is returned, instead of a formatted number.
// positive values are OK
numeral(1024).format('0.0b')
"1.0KB"
// zero and negative values return unchanged
numeral(0).format('0.0b')
"0.0"
numeral(-1024).format('0.0b')
"-1024.0"
Since none of the documentation examples show negative bytes, I wonder if this is intentional?
A workaround for negative values is to do this in client code using the library:
// if the value is negative, before displaying....
'-'+numeral(Math.abs(-1024)).format('0.0b')
"-1.0KB"
If the value is zero however, I think some other fix is required.
The text was updated successfully, but these errors were encountered:
rgravina
changed the title
When formatting a negative number as bytes, the original number is returned
When formatting zero or a negative number as bytes, the original number is returned
Nov 13, 2014
I noticed that when bytes is zero or negative, the original number is returned, instead of a formatted number.
Since none of the documentation examples show negative bytes, I wonder if this is intentional?
A workaround for negative values is to do this in client code using the library:
If the value is zero however, I think some other fix is required.
The text was updated successfully, but these errors were encountered: