How to set the lower or higher Value of a int64?
I know i can get the higher Value of a int 64 with:
int32 higher = 开发者_开发知识库(int32)(iGUID >> 32);
But how can i set it?
I tried it with this, but it says "expression must be a modifiable value":
iGUID << 32 = inewlGUID;
I need to keep the other Value, ( if i set the higher value, the lower should keep).
To change the upper 32 bits while keeping the lower ones unmodified:
iGUID = (iGUID & 0xFFFFFFFF) | (inewlGUID << 32);
iGUID = (static_cast<int64>(inewlGUID) << 32) | (iGUID & 0xffffffff);
This will preserve any existing contents.
You can also take the address of the 64 bit value and cast it to a pointer to int32
, which can then be subscripted and assigned to. This is usually not recommended, however, because it will make your code depend on the platform's byte order.
精彩评论