I want to get the low 32 bit of a int64 as int32
问题 I have an Int64 value, but I only need the lower 32 bits. Thus I want a quick way to get the Int32 value from the lower 32 bits of the Int64 value. Thanks 回答1: Do something like this: long tempLong = ((yourLong >> 32) << 32); //shift it right then left 32 bits, which zeroes the lower half of the long int yourInt = (int)(yourLong - tempLong); This may not be the most compact way to do it, but it seems to be the most readable to me. The following code will extract the high half of the long: