Let say I have two floats
0.1788877
and 0.17777231
I only want to convert them in to 0.17 and truncate all the remaining precisions.
For example, FN(0.1788877) === FN(0.17777231) should return TRUE.
What do I do?
Let say I have two floats
0.1788877
and 0.17777231
I only want to convert them in to 0.17 and truncate all the remaining precisions.
For example, FN(0.1788877) === FN(0.17777231) should return TRUE.
What do I do?
Number#toFixed(x)
returns a string representing the number with the maximum of x
digits after the decimal point.
Contverting that string to a number by +
will produce the expected result:
const FN=num=>+num.toFixed(2)