ios - Strange behaviours with stringWithFormat float -
(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 understand behaviour here? i'm running on device.
it's bug in lldb
. if try same thing in gdb
, works properly. suspect lldb
passing low 32 bits of argument. ieee representation of 0.01 , of number it's printing these:
47ae147b3778df69 = 19991592471028323832250853378750414848.00 3f847ae147ae147b = 0.01
notice low 32 bits of 0.01 match high 32 bits of other number.
the bug happens printf
:
(lldb) expr (void)printf("%.1f\n", 0.01) 19991592257096858016910903319197646848.0 <no result>
it doesn't happen +[nsnumber numberwithdouble:]
:
(lldb) po [nsnumber numberwithdouble:0.01] (id) $3 = 0x0fe81390 0.01
so suspect bug in lldb
's handling of variadic functions.
you can open bug report @ the llvm bugzilla and/or @ apple's bug reporter (aka rdar).
Comments
Post a Comment