Both are mathematical values, however the float does have more precision. Is that the only reason for the error - the difference in precision? Or is there another potential (and more ...
I have a function: int F(double a) { if (a = =1.0) { return 22; } return 44; } When I call F(1.0) it returns 22. But if I call F from a loop like: double a = 0.0; for (int j = 0; j <= 1000; j++) { std::cout << F(a) <
Next month I will start to work on a C++ based Software named CAT++ which is going to provide FORTRAN like arrays in C++ and will be used within Scientific Community and hence will heavily depend on Numerical-Computations. I was reading 29.16 ans 29.17 sections of FAQs: http://www.parashift.com/c++-faq-lit...html#faq-29.16 as a test, I just tried this program on Linux, GCC 4.2.2 and ...
Andrea B wrote:[color=blue] > Hi everybody, > > a guy told me during a job interview that we can't compare directly 2 > floats, because in very rare situations we can get wrong results. > I googled it, with no result.[/color] Funny, I just googled "float comparisons" and I got some pretty good hits. Jonathan
That's what I'm asking in the last post (when I said "is always an integer", I meant an integer, not a C int). You could check this one by printing all the bits out, I think, but I won't bother doing that either. I'm sure if the number has a fixed precision it will be okay. Oh -- and thank you ...