title: Linux and Windows millisecond time
body: <p>I want to get the milliseconds time of a system (I don't care if it's the real time, I want it to be as accurate as possible). Is this a good method to do it?</p>
  
  <pre><code>#ifdef WIN32
  unsigned long long freq;
  unsigned long long get_ms_time() {
      LARGE_INTEGER t;
      QueryPerformanceCounter(&amp;t);
      return t.QuadPart / freq;
  }
  #else
  unsigned long long get_ms_time() {
      struct timespec t;
      clock_gettime(CLOCK_MONOTONIC, &amp;t);
      return t.tv_sec * 1000 + t.tv_nsec / 1000000;
  }
  #endif
  </code></pre>
  
  <p>How can I wrap this value to a signed int? I tried doing this and I get negative values like this (on Linux, I don't know on Windows):</p>
  
  <pre><code>~ start
  -2083002438
  ~ 15 seconds after..
  -2082987440
  ~ 15 seconds after..
  -2082972441
  </code></pre>
  
  <p>I would something like this.
      ~ start
      X
      ~ 15 seconds after..
      X + 14998
      ~ 15 seconds after..
      X + 29997</p>
  
  <p>Where X is a positive number. (I want the output positive and increasing)</p>