Advertisement

64-bit integer arithmetics

Started by July 20, 2000 07:15 AM
1 comment, last by Ridcully 24 years, 5 months ago
i need to calculate the difference of two FILETIME structures. a FILETIME struct consists of two 32-bit values representing the high and low order word of a 64-bit integer. because there is no built in support for 64-bit integers i can''t just substract them how you would do with a normal integer. so how do i substract two 64-bit ints? thanks ridcully
It depends what compiler you are using. If MS VisualC++ then you
can use ULARGE_INTEGER type and LargeIntegerSubtract function.
Copy FILETIME to ULARGE_INTEGER and perform substract operation.
Btw. MS VisualC++ support __int64 type.
If you use another compiler you can write simple function, for
example:

FILETIME SubFiletime(FILETIME ftFirst, FILETIME ftSecond)
{
FILETIME ftRes;

ftRes.dwHighDateTime = ftFirst.dwHighDateTime - ftSecond.dwHighDateTime;
if (ftFirst.dwLowDateTime < ftSecond.dwLowDateTime)
{
ftRes.dwHighDateTime--;
}
ftRes.dwLowDateTime = ftFirst.dwLowDateTime - ftSecond.dwLowDateTime;

return ftRes;
}

Sergej.

Advertisement
i didn''t know ms vc++ supports 64bit integers, thanks a lot, the code is working fine now.
but i can''t find any LargeInteger... function as you mentioned. well anyways i don''t need it.

thanks again
ridcully

This topic is closed to new replies.

Advertisement