getting the lower and upper dword in an __int64

Posted on 2003-02-28
Medium Priority
Last Modified: 2012-05-04
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.
Question by:BungoMan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8046905
#define HiDWord(x)    ((x>>32) & 0xffffffff) // 8 letters F
#define LoDWord(x)    ((x)     & 0xffffffff) // 8 letters F

with x's type is __int64
LVL 22

Accepted Solution

nietod earned 200 total points
ID: 8047444
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);


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question