Argh, division doesn't work sometimes! Check this out...
Okay, someone answer me this...
I feel like I am in the twilight zone. I have very simple arithmetic here, yet the compiler generates different results for some odd reason!
Basically I am dividing 731961 by 365.25 and the result should be exactly 2004 (no decimal). Here's some code:
Code:
unsigned x = 731961;
int y = 365;
std::cout << "\n" << x << " / " << (y + .25) << " = " <<
int(x / (y + .25));
////////////////////////////////////////
// what the eff???
std::cout << "\n-->" << x << " / " << (y + .25) << " = " <<
int(x / (365 + .25));
std::cout << "\n-->" << x << " / " << (y + .25) << " = " <<
int(x / (DPY + .25));
////////////////////////////////////////
std::cout << "\n" << x << " / " << (y + .25) << " = " <<
int(731961 / (y + .25));
std::cout << "\n" << x << " / " << (y + .25) << " = " <<
int(731961 / (365 + .25));
std::cout << "\n" << x << " / " << (y + .25) << " = " <<
int(731961 / (DPY + .25));
This outputs this:
Quote:
731961 / 365.25 = 2004
-->731961 / 365.25 = 2003
-->731961 / 365.25 = 2003
731961 / 365.25 = 2004
731961 / 365.25 = 2004
731961 / 365.25 = 2004
Do you have any effin clue why this is happening???? Argh!