• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2145
  • Last Modified:

getting the lower and upper dword in an __int64

i know there is a HIWORD and LOWORD function (well... sorta.. i found where it was and its actualy a #define macro thingy... anyways..) for dwords (or any 4byte int), but i was wondering if someone knows how to or knows of an existing function to get the lower and upper dwords in a __int64 type qword.
0
BungoMan
Asked:
BungoMan
1 Solution
 
thienpnguyenCommented:
#define HiDWord(x)    ((x>>32) & 0xffffffff) // 8 letters F
#define LoDWord(x)    ((x)     & 0xffffffff) // 8 letters F

with x's type is __int64
0
 
nietodCommented:
I would STRONGLY recommend you don't do that with C/C++ macros (#defines).  and if you do, you write them differently.   The version above will work incorrectly if you do things like

int x = LoDWord(5+3);

Write them as real C/C++ functions and you will get much better behavior.

DWORD LoDWord(__int64 x)
{
    return x  & 0x0FFFFFFFF;
}

DWORD HiDWord(__int64 x)
{
    return LoDWord(x >> 32);
}

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now