Possible duplicate:Is JavaScript math broken?
Why in some programming languages โโdoes the expression in the header evaluate to true? I tried this in php, ruby โโand python.
Read What Every Programmer Should Know About Floating-Point Arithmetic.
What Every Programmer Should Know About Floating-Point Arithmetic
double TOLERANCE < 1.0E-10; if(fabs(0.1+0.7-0.8)< TOLERANCE) { std::cout << "0.1 + 0.7 == 0.8" << std::endl; } else { std::cout << "0.1 + 0.7 != 0.8" << std::endl; }
Due to the internal interpretation of floating point numbers, they do not exactly match what you wrote.
Source: https://habr.com/ru/post/1782933/More articles:How can I report the custom NSWindow header to the accessibility system? - accessibilityCount recursion steps in java - javaHanoi Tower, stop moving - javaAndroid ADB API from C / C ++ Applications - c ++How to add line feed to header style tooltip in firefox? - htmlAndroid How do you support the old API without having 2 compiled .apk files when using methods from the newer APIs? - androidMy SQL captures the last active users in one week - mysqlWhat is the best way to deal with different versions of Android? - androidProblems compiling FMOD - c ++Mobile web application platform in Java or PHP - javaAll Articles