title: iPhone - Storing a double value into a NSDictionary with only 7 decimals as a Number type
body: <p>I have a PList that contains a dictionary with some decimal values like 10.1234567, stored as Number type (tag ).<br>
  In my app, I read that plist and manipulate those values as NSNumber (double type values) with a custom class and its accessors : </p>
  
  <pre><code>@interface
  ...
  @property(nonatomic, assign) NSNumber* someValue;
  ...
  @end
  
  @implementation
  ...
  - (NSNumber*) someValue { return [self.dict objectForKey:@"val"]; }
  - (void) setSomeValue:(NSNumber*)val { [self.dict setValue:val forKey:@"val"]; }
  ...
  @end
  </code></pre>
  
  <p>Then in some case, I write back on the disk the plist.  </p>
  
  <p>I've notice a few hours ago that those values where, let's say, converted and are now something like 10.123456699999999. All of them ! ...</p>
  
  <p>Woaw, I didn't expected that change. </p>
  
  <p>Well, I've tried to contain the problem changing the accessors with many thing, like for example this one :</p>
  
  <pre><code>- (NSNumber*) someValue { return [self.dict objectForKey:@"val"]; }
  - (void) setSomeValue:(NSNumber*)val { [self.dict setValue:
                                                [NSNumber numberWithDouble:[[NSString stringWithFormat:@"%.7lf", [val doubleValue]] doubleValue]] 
                                                            forKey:@"val"]; }
  </code></pre>
  
  <p>But I can't succeed keeping those value stay with their original 7 decimals.</p>
  
  <p>How may I do to write only 7 decimals, without having to use something else than a Number type for the field into the dictionary (I mean, using a String wouldn't be a good solution) ?</p>
  
  <p>The creation of the plist file was made by hand, with some hours of typing, typing those 7 decimal values into each field, and they weren't "converted" at that moment. They were stored with 7 decimal. So I guess there is a solution to keep those 7 decimals when writing them back by program.</p>