0

How can I store '0.07' value except NSDecimalNumber? I mean I can't using NSDecimalNumber because when I'm using doubleValue function, decimal 0.07 becomes 0.0699999... double or something else, but never 0.07 double :)

Example from debugger:

(lldb) po [[NSDecimalNumber alloc] initWithDouble:.07]
0.07000000000000001024

(lldb) po [[NSDecimalNumber alloc] initWithDouble:(double).07]
0.07000000000000001024

(lldb) po [[[[NSDecimalNumber alloc] initWithDouble:7] decimalNumberByDividingBy:[[NSDecimalNumber alloc] initWithDouble:100]] doubleValue]
0.069999999999999993

(lldb) po 0.07
0.070000000000000007

(lldb) po (double)0.07
0.070000000000000007

The only way to store 0.07 is NSDecimalNumber, but it's inconvenient:

(lldb) po [[[NSDecimalNumber alloc] initWithDouble:7] decimalNumberByDividingBy:[[NSDecimalNumber alloc] initWithDouble:100]]
0.07
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Vasilii Muravev
  • 3,063
  • 17
  • 45

0 Answers0