|
How to convert _uint64 into two _uint32 values and vice versa.
Regards,
Vishal
|
|
|
|
|
By shifting the high part and casting:
_uint64 ui64 = 1234;
_uint32 lo = (_uint32)ui64;
_uint32 hi = (_uint32)(ui64 >> 32);
ui64 = (_uint64)lo | ((_uint64)hi) << 32;
[EDIT:] Added code formatting.
|
|
|
|
|
does it take endianness into consideration, (Little/Big Endian)
Regards,
Vishal
|
|
|
|
|
Yes, because the endianess does not care for the used logical operations.
If you think of multiplication / division instead of the shift operations and of addition instead of the OR operation it should be clear. The operation values are just high or low parts where the internally used bit or byte order does not care. Casting is similar (extending with high zeroes upon up-casting and masking out the lower bits upon down-casting).
|
|
|
|
|
Thank you..
Regards,
Vishal
|
|
|
|
|
Here is another way to do it using the LARGE_INTEGER[^] union.
LARGE_INTEGER lint;
lint.QuadPart = 12345;
|
|
|
|
|
I too came across the union while using GetFileSize function.
does it produces same result in little endian and big endian systems.
as i want this for encryption section, where i had to convert 64bit unsigned integer to two 32 bit unsigned integer and vice versa,
So looking for results on little endian and big endian system result.
Regards,
Vishal
|
|
|
|
|
Yes, this will give you correct results irrespective of the endian-ness.
|
|
|
|
|
very very thank you sir.
Regards,
Vishal
|
|
|
|