Jump to content
  • Advertisement
Sign in to follow this  
Dom_152

LARGE_INTEGER on 32 bit system

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
QFE!
Quote:
Original post by Adam_42
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!