Archived

This topic is now archived and is closed to further replies.

Ridcully

64-bit integer arithmetics

Recommended Posts

Ridcully    122
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

Share this post


Link to post
Share on other sites
DLife    122
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.

Share this post


Link to post
Share on other sites
Ridcully    122
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

Share this post


Link to post
Share on other sites