(lldb) po [NSString stringWithFormat:@"%.1f", 0.01]
(id) $21 = 0x003a2560 19991592471028323832250853378750414848.0
(lldb) po [NSString stringWithFormat:@"%.1f", 0.1]
(id) $22 = 0x0de92240 -0.0
Does anyone understand the behaviour here? I’m running on device.
It’s a bug in
lldb. If you try the same thing ingdb, it works properly. I suspectlldbis only passing the low 32 bits of the argument. The IEEE representation of 0.01 and of the number it’s printing are these:Notice that the low 32 bits of 0.01 match the high 32 bits of the other number.
The bug also happens with
printf:It doesn’t happen with
+[NSNumber numberWithDouble:]:So I suspect the bug is in
lldb‘s handling of variadic functions.You can open a bug report at the LLVM bugzilla and/or at Apple’s bug reporter (aka rdar).