LARGE_INTEGER on 32 bit system

Started by
5 comments, last by Bimble Bob 13 years, 9 months ago
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?
It's not a bug... it's a feature!
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.
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
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?

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.
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.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
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.
It's not a bug... it's a feature!

This topic is closed to new replies.

Advertisement