Search Results

Search found 1 results on 1 pages for 'mirkules'.

Page 1/1 | 1 

  • NSNumber floatValue not equal to NSNumber value

    - by Mirkules
    Hi Everyone, First post here. Having a problem with NSNumber's floatValue method -- somehow, it returns an imprecise number. Here's the problem: I store a bunch of NSNumbers in an array, like this: NSArray *a = [NSArray arrayWithObjects: [NSNumber numberWithFloat:0.04f], [NSNumber numberWithFloat:0.028f], [NSNumber numberWithFloat:0.016f], [NSNumber numberWithFloat:0.004f], nil]; Then I try to retrieve the first value (for example): NSNumber n = (NSNumber) [a objectAtIndex:0]; CGFloat f = [n floatValue]; In the debugger, n shows a value of 0.04 (in the summary column), but f shows a value of 0.0399999991. What am I doing wrong here? Thanks everyone.

    Read the article

1