Simple divison has GONE MAD!
-
I have a variable int that when I divide by 2, it all on it's own it divides by 4. By playing with it, I figured out that if I mulitply by about the square root of 2 / 2 the computer simply divides by two. I've even rebuilt the whole project. The int is normally around 3,000,000 and the only thing I can think is that maybe it's larger than it may legally be. So I tried casting it to double, but I got the same responce. Any and all help is greatly appreciated. If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
-
I have a variable int that when I divide by 2, it all on it's own it divides by 4. By playing with it, I figured out that if I mulitply by about the square root of 2 / 2 the computer simply divides by two. I've even rebuilt the whole project. The int is normally around 3,000,000 and the only thing I can think is that maybe it's larger than it may legally be. So I tried casting it to double, but I got the same responce. Any and all help is greatly appreciated. If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.
This is mighty weird. What are the exact lines of code that are doing the division?
-
This is mighty weird. What are the exact lines of code that are doing the division?
int iDecryptID = m_iID; iDecryptID /= 2; return iDecryptID;
By returning m_iID I know that it is, in fact, the divison that is the problem. If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395. -
int iDecryptID = m_iID; iDecryptID /= 2; return iDecryptID;
By returning m_iID I know that it is, in fact, the divison that is the problem. If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.Nope, the division is working properly. The chance of a compiler error is very very very small. If the output isn't matching the expected value, then the input isn't what you think it is or something else is going on. With strange problems like this, 99.9999% of the time it is the programmer who is making assumptions that are wrong. Tim Smith I'm going to patent thought. I have yet to see any prior art.
-
int iDecryptID = m_iID; iDecryptID /= 2; return iDecryptID;
By returning m_iID I know that it is, in fact, the divison that is the problem. If you have a problem with my spelling, just remember that's not my fault. I (as well as everyone else who learned to spell after 1976) blame it on Robert A. Kolpek for U.S. Patent 4,136,395.Can you post more context? I'm quite sure that,
#include <iostream%gt;
int Bogus ( int nTest )
{
int iPart = nTest ;
iPart /= 2 ;
return iPart ;
}int main ()
{
std::cout << "Result of Bogus ( 3000000 ) = " << Bogus ( 3000000 ) << std::endl ;
return 0 ;
}will be as expected.
Paul