Hi All, Is there a function within suitescript 2 t...
# suitescript
b
Hi All, Is there a function within suitescript 2 that allows the rounding of numbers? I'm doing a calculation multiplying two values together but I want to round the result. Thanks in advance.
n
r
You could also use this parseFloat().toFixed(2) But math.round will handle the exception scenarios.
b
if you are trying to be precise with currency, .toFixed rounds differently than humans do
the most common example being
Copy code
1.005.toFixed(2)
rounding differently than you would expect
common workaround are to use exponential notation shifting, which is what the lodash round does
or an arbitrary precision library like big.js
b
Thanks all.. Math.round has done the job.
I was rounding Colombian Peso's to get rid of the loose change.