5

On iOS 4.3 Simulator, the following code returns a very small number: 1e-700 on GCC 4.2, but works as expected on LLVM-GCC 4.2. Any ideas?

NSDate *selectedDate = self.datepicker.date; // guaranteed to be before now
NSTimeInterval interval = [nowDate timeIntervalSinceDate:selectedDate];

these values change with each run, but here is an example set of output

selectedDate: 1981-06-02 16:27:34 +0000

nowDate: 2011-08-03 05:18:36 +0000

interval: 5.489011535689859e-277

running [nowDate timeIntervalSinceDate:selectedDate] in GDB: 952001462.97236204 (this is my expected value)

Justin Spahr-Summers
  • 16,893
  • 2
  • 61
  • 79
Heath Borders
  • 30,998
  • 16
  • 147
  • 256

2 Answers2

0

This might be a bug with GCC. I think you should fill a bug report and see what Apple has to say.

David Murray
  • 541
  • 5
  • 19
-1

The unexpected value is an overflow.

Ameer Sheikh
  • 770
  • 5
  • 14