regarding TInt64
| Wed, 2008-01-30 07:37 | |
|
HI, I am doing an operation y = x*(10^6) where x is of type TInt and y is of type TInt64. now when the result crosses 2^31, the msb of y becomes FFFF FFFF and lsb of y contains the proper result. Can anybody explain why the msb gets that value? the msb is 0 before y crosses 2^31. |
|






Forum posts: 1246
You might have better luck if you try:
y = ((TInt64)x)*(10^6);
or you risk overflow.
I'm pretty sure your code would mean a 32 bit multiplication, and then the _result_ gets sign-extended to a TInt64.
If you cast the x first, the multiplication will be 64 bit, and you wont lose information in it.