Jump to content
  • Advertisement

Archived

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

Ridcully

64-bit integer arithmetics

This topic is 6546 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 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
Advertisement
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
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

  • 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!