I have verified and I cannot find canonical information about the errors that occur when doing calculations with javascript.
such a simple example with addition:
>0.1 + 0.2
0.30000000000000004
or when doing this subtraction:
>1.7-1.6
0.10000000000000009
It seems wrong to me that in 2020 it is not known exactly why these errors occur; or in my case I can’t find a canonical answer.
I also don’t make sense to it, that there is no native solution and programmers find it necessary to use the .toFix () method to solve this precision problem.
the issue is for all computer since binary system which has no correct way to represent the 0.1
check this
idk if that available in js but in other language like in java it’s recommended to not use the primitive type for float numbers calculations which has built-in class that fix that issue
what i meant that in java the 2 option avilable but it’s the developer choice to use the class or primitive type
if you have the name of the class could you tell me it’s name so i check if it supported in mozilla or any browser