In JavaScript, is it possible to "lock" a decimal number, to preserve "floating point" numbers that end with zeroes?
Example, I have 2 different numbers, like this: (pseudo code)
let a = 1.0;
let b = 1.00;
a === b // true, should be false, because different decimals.
print(a) // "1", should be "1.0"
print(b) // "1", should be "1.00"
(should also be different from a "true int" 1
)
I want them to identify as different from each other, because they have different amount of zeroes at the end.
But stupidly "efficient" JavaScript rounds them both down to "integer" 1
& therefore they are equal.
I am aware of the Number.toFixed(Number)
& Number.toPrecision(Number)
functions, but to use them like this I have to first calculate the length of the number, which I can't because JavaScript have already rounded away the zeroes.
I have also been thinking of "cutting" off the number at the decimal point & store them in an array... but again, rounded to an "int" without a decimal point.
(Yes, I know that the concept of "float" doesn't exist in JS, I use it here to diferentiate between numbers with or without decimals).
Thanks for any help.