regarding TInt64

Login to reply to this topic.
Wed, 2008-01-30 07:37
Joined: 2007-09-18
Forum posts: 8

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.


Wed, 2008-01-30 09:34
Joined: 2004-11-29
Forum posts: 1246
Re: regarding TInt64

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.

  • Login to reply to this topic.