title: time(NULL) Returning Inconsistent Values on Macbook Pro
body: <p>What does <code>time(NULL)</code> return? Given documentation I had assumed it returns the number of seconds since epoch, however, when I run the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Time.h"
  #include "Math.h"
  
  int main () {
  
      double curT = 0;
      double curJ = 0;
  
      time_t curTtimeT = 0;
      double curJtimeT = 0;
  
      //run indefinitely... use a debugger you can stop :-)
      for (double j = 0; j &lt; 2000000000; j++) {
  
          //get the current time
          curT = time(NULL);
          curTtimeT = time(NULL);
  
          //check if current time equals previous time
          if (time(NULL) != curT) {
              //output time and approx. "time" through iteration
              std::cout &lt;&lt; "Time match with doubles:\t" &lt;&lt; curT &lt;&lt; "\tdeltaJ:\t\t\t" &lt;&lt; (j - curJ) &lt;&lt;std::endl;
              curT = time(NULL);
              curJ = j;
          }
  
          if (time(NULL) != curTtimeT) {
              //output time and approx. "time" through iteration
              std::cout &lt;&lt; "Time match with time_t:\t\t" &lt;&lt; curTtimeT &lt;&lt; "\t\tdeltaJtimeT:\t\t" &lt;&lt; (j - curJtimeT) &lt;&lt;std::endl;
              curTtimeT = time(NULL);
              curJtimeT = j;
          }
  
      }
      return 0;
  }
  </code></pre>
  
  <p>I get the following results (the skipping does not appear to have a pattern between runs):</p>
  
  <pre><code>Time match with time_t:     1348873002      deltaJtimeT:        290842
  Time match with doubles:    1.34887e+09 deltaJ:         2.41017e+06
  Time match with doubles:    1.34887e+09 deltaJ:         1.08409e+06
  Time match with doubles:    1.34887e+09 deltaJ:         2.16587e+06
  Time match with time_t:     1348873007      deltaJtimeT:        5.36928e+06
  Time match with doubles:    1.34887e+09 deltaJ:         1.08696e+06
  Time match with time_t:     1348873008      deltaJtimeT:        1.08696e+06
  Time match with doubles:    1.34887e+09 deltaJ:         1.08534e+06
  Time match with doubles:    1.34887e+09 deltaJ:         3.18296e+06
  ...
  Time match with time_t:     1348873122      deltaJtimeT:        2.16217e+06
  Time match with doubles:    1.34887e+09 deltaJ:         6.42553e+06
  Time match with doubles:    1.34887e+09 deltaJ:         1.08727e+06
  Time match with doubles:    1.34887e+09 deltaJ:         2.14147e+06
  Time match with doubles:    1.34887e+09 deltaJ:         1.04733e+06
  Time match with time_t:     1348873130      deltaJtimeT:        8.42965e+06
  </code></pre>
  
  <p><em>Note: I am using the <code>deltaJ</code> output to show a bit more numerically what is a clear visual difference in terms of when the console actually outputs results from this loop.</em></p>
  
  <p>Clearly, this does not seem to consistently be returning the number of seconds since epoch, as I would instead be able to see a very consistent output of very close to 1 line for both <code>double</code> and <code>time_t</code> per second. Instead, I miss the entire range between <code>1348873002</code> and <code>1348873007</code> - none of these values appear to be found via <code>time(NULL)</code>. These gaps appear consistently throughout the entire runtime of this loop. </p>
  
  <p>Additionally, sometimes it does not even output for some of the seconds (see the gap between <code>1348873122</code> and <code>1348873130</code>).</p>
  
  <p>I don't understand why the output doesn't show one entry for both variable types, for each second of real time. Instead, it seems <code>time(NULL)</code> inconsistently returns the number of seconds since epoch, and actually skips some values.</p>
  
  <p>What am I missing?</p>
  
  <p>I am running these tests on a 2.4GHz dualcore Macbook Pro, in X-Code 3.2.5, on Snow Leopard (perhaps this issue is specific to my system)?</p>