Is there any set of functions that would allow easy manipulation of ULARGE_INTEGER's? Currently I'm trying to devise a way to handle the addition of one of these with a smaller number, handling overflow as the problem arises. Since a ULARGE_INTEGER is basically a collection of two DWORD's, the difficulty comes in detecting whether the smaller number added to the LowPart member is larger than the maximum DWORD value and adding the overflow to the HighPart member. I've constructed a code snippet that shows what I want to do:
Theoretically, if the addition of someArbitraryValue will overflow the LowPart member of the large integer, the result of the addition is shifted to the right by the size of a DWORD and added to the HighPart member to ensure that only the overflow amount is added to the high DWORD. The arbitrary value is then added to the LowPart member in either case under the assumption that any overflow would occur "quietly," causing LowPart to roll over as it should, but not affecting any other memory. Seem plausible?Code:ULARGE_INTEGER timeDifference; double newTimeLimit; DWORD maxDWORDValue; int someArbitraryValue; memset(&maxDWORDValue, 255, sizeof(DWORD)); newTimeLimit = timeDifference.LowPart + someArbitraryValue; if (newTimeLimit > maxDWORDValue) { timeDifference.HighPart += newTimeLimit >> sizeof(DWORD); } timeDifference.LowPart += someArbitraryValue;
By the way, I can't use int64 because Dev-C++ doesn't recognize it as a built-in type.