Possible Duplicate:
Floating point inaccuracy examples
double a = 0.3; std::cout.precision(20); std::coutresult: 0.2999999999999999889
double a, b; a = 0.3; b = 0; for (char i = 1; iresult: 15.000000000000014211
So.. 'a' is smaller than it should be. But if we take 'a' 50 times - result will be bigger than it should be.
Why is this? And how to get correct result in this case?
0 answers
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20529
7
13638
4






