Anybody have any idea why this function is returni...
# suitescript
a
Anybody have any idea why this function is returning null for numbers like:
Copy code
9.269169061970037e-7
2.3255506128392395e-7
0.00000306549853510627
0.000004475363594140059
0.0000166455249120695
I has been using this function for years without any issue.
b
it probably shouldnt work for the numbers with scientific notation in them
a
That should not matter, a number is always a number, the notation is just a visual representation when you log the value...
b
Copy code
paramValue + 'e' + paramDecimals
its converted to a string
9.269169061970037e-7 + 'e' + 2 === "9.269169061970037e-7e2"
the output of your function should be NaN at the end for numbers that have scientific notation in their string representations
hopefully thats your output instead of null. null isnt a normal output of the Number constructor
a
I'm trying to just round those numbers to two decimal places, does not matter if they have exponential notation or not.
b
use the original function that handles exponents
or use something like https://github.com/MikeMcl/decimal.js/ which supports arbitrary precision decimals
s
I've been meaning to adopt decimaljs