2

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).

Sapd
  • 27
  • 4

2 Answers2

3

To change the upper 32 bits while keeping the lower ones unmodified:

iGUID = (iGUID & 0xFFFFFFFF) | (inewlGUID << 32);
hammar
  • 138,522
  • 17
  • 304
  • 385
0
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.

Alexander Gessler
  • 45,603
  • 7
  • 82
  • 122