title: Int to Double casting issue
body: <p>I'm an Objective-C developer with little C/C++ experience (and zero training), and I encountered something strange today with hard coded numeric values.</p>
  
  <p>I'm sure it's a simple/stupid question, but can someone please explain why this works:</p>
  
  <pre><code>NSDate *start = [NSDate date];
  dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
  
  dispatch_after(popTime, dispatch_get_main_queue(), ^{
    NSLog(@"seconds: %f", [start timeIntervalSinceNow]);
  });
  // output: seconds: -1.0001
  </code></pre>
  
  <p>And this also works (note number of seconds has changed):</p>
  
  <pre><code>NSDate *start = [NSDate date];
  dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
  
  dispatch_after(popTime, dispatch_get_main_queue(), ^{
    NSLog(@"seconds: %f", [start timeIntervalSinceNow]);
  });
  // output: seconds: -2.0001
  </code></pre>
  
  <p>But this is executed immediately:</p>
  
  <pre><code>NSDate *start = [NSDate date];
  dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 4 * NSEC_PER_SEC);
  
  dispatch_after(popTime, dispatch_get_main_queue(), ^{
    NSLog(@"seconds: %f", [start timeIntervalSinceNow]);
  });
  // output: seconds: -0.0001
  </code></pre>
  
  <p>However, using <code>4.0</code> instead of <code>4</code> fixes it:</p>
  
  <pre><code>NSDate *start = [NSDate date];
  dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 4.0 * NSEC_PER_SEC);
  
  dispatch_after(popTime, dispatch_get_main_queue(), ^{
    NSLog(@"seconds: %f", [start timeIntervalSinceNow]);
  });
  // output: seconds: -4.0001
  </code></pre>
  
  <p>Why do 1 and 2 properly cast to the relevant double value, but bigger numbers (I tested 3 and 4) appear to be represented as <code>0</code>?</p>
  
  <p>I'm compiling with Xcode 4.2, configured to use LLVM 3.0.</p>
  
  <p>EDIT:</p>
  
  <p>dispatch_time_t is defined as:</p>
  
  <pre><code>typedef uint64_t dispatch_time_t;
  </code></pre>
  
  <p>And dispatch_time is:</p>
  
  <pre><code>dispatch_time_t dispatch_time(dispatch_time_t when, int64_t delta);
  </code></pre>
  
  <p>And NSEC_PER_SEC is:</p>
  
  <pre><code>#define NSEC_PER_SEC    1000000000  /* nanoseconds per second */
  </code></pre>