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
round(11111111111111111111,2)`${value}e${decimals}`// '11111111111111110000e2'Number(`${value}e${decimals}`)// 1.111111111111111e+21`${Math.round(Number(`${value}e${decimals}`))}e-${decimals}`// '1.111111111111111**e+21e-2**'Number(`${Math.round(Number(`${value}e${decimals}`))}e-${decimals}`);// NaN
20 and 21 characters, with decimals, seems to be some barrier where the original value does not contain e, but adding the decimals does add it, whereafter the rounding breaks it by adding another exponent, breaking the floating point representation.
Seemed fairly obvious I thought - but they were all of them deceived, it's only after trying to solve the issue where I started noticing the floating point precision issue as well (Notice the input of 11111111111111111111, becoming 11111111111111110000e2). As JS only has 16-ish points of precision (IEEE 754) this issue is of course both for the succeeding, and the failing example.
I got no solution at this point to accept BigDecimals and successfully round them up, tried many things, will try more things.
The text was updated successfully, but these errors were encountered:
Bit of a journey, we found out that 20 and 21 characters result into NaN, which throws the IsNumber validation.
I played around with the rounding function to see where the issue lies:
Success
Fail
20 and 21 characters, with decimals, seems to be some barrier where the original value does not contain
e
, but adding the decimals does add it, whereafter the rounding breaks it by adding another exponent, breaking the floating point representation.Seemed fairly obvious I thought - but they were all of them deceived, it's only after trying to solve the issue where I started noticing the floating point precision issue as well (Notice the input of 11111111111111111111, becoming 11111111111111110000e2). As JS only has 16-ish points of precision (IEEE 754) this issue is of course both for the succeeding, and the failing example.
I got no solution at this point to accept BigDecimals and successfully round them up, tried many things, will try more things.
The text was updated successfully, but these errors were encountered: