0
Why when using float numbers, like adding,0.1 +0.2 !=0.3, and gives off a huge decimal number?
I wish to know how, why this happens and how can I just represent just a simple two units after the decimal. thank you in advance.
2 Réponses
+ 3
It is linked to the accuracy/precision problem with floating point numbers and is a general caveat in programming. Read about it here, for example:
https://en.m.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems
For displaying such numbers, either rounding or adequate formatting is used, most often.
+ 2
I know how, but it's JavaScript language. Sorry.