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
If we do something like this in Chrome browser: parseInt(-0.49999) it gives us the result -0.
This is the odd JavaScript behavior, but indeed, I think it should be handled in Highcharts.numberFormat function, which now returns the string '-0', like in this demo: https://jsfiddle.net/BlackLabel/9jnfd6s7/ (see console)
numberFormat function can be fixed with something like this: https://jsfiddle.net/BlackLabel/bdg4rej5/ Fix after comment // --- FIX, then it gives us the 0 without the minus sign.
According to Wikipedia, signed zeroes are used in computing. But in practice I agree it looks odd, as our formatted numbers are intended for human interpretation. I'm happy with changing the numberFormat function.
Informally, one may use the notation "−0" for a negative value that was rounded to zero. This notation may be useful when a negative sign is significant; for example, when tabulating Celsius temperatures, where a negative sign means below freezing.
But we don't know that at the time of formatting, so unless we want to add another option to the number formats, I think we should just fix it.
Activity
hubertkozik commentedon Feb 1, 2024
Hi @jomar-honsi!
If we do something like this in Chrome browser:

parseInt(-0.49999)it gives us the result-0.This is the odd JavaScript behavior, but indeed, I think it should be handled in
Highcharts.numberFormatfunction, which now returns the string '-0', like in this demo: https://jsfiddle.net/BlackLabel/9jnfd6s7/ (see console)numberFormatfunction can be fixed with something like this: https://jsfiddle.net/BlackLabel/bdg4rej5/ Fix after comment// --- FIX, then it gives us the 0 without the minus sign.Can I ask for your opinion @TorsteinHonsi?
TorsteinHonsi commentedon Feb 1, 2024
The
toFixedmethod also returns -0 in this case:console.log(-0.4999.toFixed(0)); // => -0According to Wikipedia, signed zeroes are used in computing. But in practice I agree it looks odd, as our formatted numbers are intended for human interpretation. I'm happy with changing the
numberFormatfunction.TorsteinHonsi commentedon Feb 1, 2024
PS: The same Wikipedia article states that
But we don't know that at the time of formatting, so unless we want to add another option to the number formats, I think we should just fix it.
Fixed #20564, minus sign was displayed for number zero.