05-19-2005, 11:58 PM
Blitz,
Sorry, I had no intentions of insulting you, just giving you the facts.
In you last solution, your answers cannot be expressed as 16 bit integers, because you are working with long integers. Don't feel bad, my personal solution had the same problem.
Examples:
1) For a num of 8192, your result is 32768, which cannot be expressed in a 16 bit integer. It should be -32768.
2) For a num of 16383, your result is 65532, which cannot be expressed in a 16 bit integer. It should be -4.
A simple fix would be to take the result from your function and store it into an integer variable before displaying it.
If you look at your results expressed in hex, they're ok.
What do you think?
*****
Sorry, I had no intentions of insulting you, just giving you the facts.
In you last solution, your answers cannot be expressed as 16 bit integers, because you are working with long integers. Don't feel bad, my personal solution had the same problem.
Examples:
1) For a num of 8192, your result is 32768, which cannot be expressed in a 16 bit integer. It should be -32768.
2) For a num of 16383, your result is 65532, which cannot be expressed in a 16 bit integer. It should be -4.
A simple fix would be to take the result from your function and store it into an integer variable before displaying it.
If you look at your results expressed in hex, they're ok.
What do you think?
*****