Thread: what is the relation between low– high part and the QuadPart in a UlargeInteger?

  1. #1
    Registered User
    Join Date
    Aug 2018
    Posts
    7

    what is the relation between low– high part and the QuadPart in a UlargeInteger?

    Hello Guys,
    I work with windows 10 and VisualStudio; I should transform window FileTime in Unix time (Epoch time); I found the formula to convert the number of seconds in the windows FileTime to number of seconds in the Unix time: Unix time = (windows FileTime/10000000) - 11644473600.
    In order to work with the window file time structure I have to “copy the low- and high-order parts of the file time to a ULARGE_INTEGER structure, perform 64-bit arithmetic on the QuadPart member” (from Microsoft doc).

    What is not clear to me and I would like to ask you is: what is the relation bewtween low – high parts and the QuadPart? If I print these three numbers (see code below), I do not see the relation.
    Here we have the code:

    Code:
    #include <stdio.h>
    #include <windows.h>
    
    int main()
    {
    
    ULARGE INTEGER U;
    FILETIME T;
    
      GetSystemTimeAsFileTime(&T);
      U.LowPart=T.dwLowDateTime;
      U.HighPart=T.dwHighDateTime;
      printf(“Windows FileTime, QuadPart: %llu \n HighPart: %lu \n LowPart: %lu \n”, U.QuadPart, U.HighPart, U.LowPart);
    
    //Unix time calculation:
    
      U.QuadPart = U.QuadPart/10000000 – 11644473600;
      printf(“Unix Time: %llu \n”, U.QuadPart);
      return 1;
    }
    Thank you for your help
    Kind regards

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,745
    Quadpart = Highpart << 32 + Lowpart

    If you print them all in hex, you should see the relationship much more easily.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2018
    Posts
    7
    Dear Salem,
    thank you for your explanation
    kind regards
    Alberto

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. High Low Game with High Scores
    By Bradley Buck in forum C Programming
    Replies: 24
    Last Post: 05-27-2011, 12:42 PM
  2. Replies: 0
    Last Post: 08-25-2010, 08:04 AM
  3. Recurrence Relation..Help needed!
    By anirban in forum Tech Board
    Replies: 2
    Last Post: 03-04-2009, 12:01 PM
  4. Executable-code relation
    By willkoh in forum C Programming
    Replies: 2
    Last Post: 03-25-2005, 02:48 PM
  5. relation explaination
    By asli_masti in forum C Programming
    Replies: 1
    Last Post: 08-28-2003, 06:55 AM

Tags for this Thread