# LARGE_INTEGER on 32 bit system

This topic is 3106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a question about how you would handle the LARGE_INTEGER union (Or any 64 bit representation using two separate 32 bit values) on a 32 bit system. I know that it would be made up of HighPart and LowPart but I have no idea how you would be expected to perform arithmetic on it or covert it to a string or something on a 32 bit system since clearly the HighPart is going to have a value of at least 2 ^ 32 (Excluding 0) which isn't able to be interpreted on a 32 bit system, is it?

##### Share on other sites
Use the .QuadPart member. It's a 64-bit integer that even a 32-bit program can happily do maths on - the compiler does the hard work for you.

##### Share on other sites
And just to clarify, HighPart and LowPart are both just 32 bits, with the following condition (sans casting) being true on compilers that natively support 64-bit integers:
QuadPart == (HighPart << 32) & LowPart

##### Share on other sites
I'm not trying to make fun of the OP, just illustrate that we all learned how to do this conceptually in elementary school:

How would you handle two-digit numbers in base 10? I know that it would be made up of HighPart and LowPart but I have no idea how you would be expected to perform arithmetic on it with only the digits 0 through 9 since clearly the HighPart is going to have a value of at least ten, which can't be interpreted with a 0-through-9 digit, right?

##### Share on other sites
I suppose without using some library call (which one, I really don't know) you'd have to program the math itself. 32 bit math works because the 32-bit CPU knows "what to do" ie... it has hardware to do all the add, subtract, whatever you want on the 32-bit integer... since your 32-bit cpu is unable to do that, you will likely have to write the software equivalent... or like I mentioned... find a library that does it for you and use that.

If you're looking for performance though... these 64-bit compatibility software operations will be pretty slow relative to how it's implemented I would imagine.

Also, if you decide to go down the "do it yourself" approach... don't forget about the sign bit... might have some fun [mis]interpreting that.

##### Share on other sites
QFE!
Quote:
 Original post by Adam_42Use the .QuadPart member. It's a 64-bit integer that even a 32-bit program can happily do maths on - the compiler does the hard work for you.

##### Share on other sites
For the record I know that the QuadPart is what I should be using and I do use it. This post was not about the practical side of things.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 10
• 9
• 37
• 16
• ### Forum Statistics

• Total Topics
634125
• Total Posts
3015682
×