Michael Waterfall
Michael Waterfall

Reputation: 20569

Problem with NSNumber (double values are off by 1)

I'm getting the following output and I've no idea why!? The resulting number is off by 1.

I thought that double's can handle massive numbers? I'm sure I'm not understanding something correctly! Any help would be greatly appreciated.

(gdb) print (double) [[NSNumber numberWithDouble:9606977671929857.0] doubleValue]
$13 = 9606977671929856

Many thanks!

Upvotes: 0

Views: 418

Answers (1)

Marcelo Cantos
Marcelo Cantos

Reputation: 186068

You've exhausted the precision of the double-precision floating point type, which only has room for about 14 significant digits in decimal notation.

Upvotes: 4

Related Questions