Some calculation problems with javascript (request canonical documentation)

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

or when doing this subtraction:


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.

Hello @ArcanisGK507

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

hope that help and have a nice day

hello @justsomeone
thanks for your answer there is some modern native class inside javascript to handle this; What is Mozilla implementing?

you very welcome @ArcanisGK507

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

and have a nice day :slight_smile: