double test1 = 5.58f;
NSString *test2 = @"5.58";
NSLog(@"%@", [NSNumber numberWithDouble:test1]);
NSLog(@"%@", [NSNumber numberWithDouble:[test2 doubleValue]]);
出力:
5.579999923706055
5.58
変換が異なるのはなぜですか?
double test1 = 5.58f;
NSString *test2 = @"5.58";
NSLog(@"%@", [NSNumber numberWithDouble:test1]);
NSLog(@"%@", [NSNumber numberWithDouble:[test2 doubleValue]]);
出力:
5.579999923706055
5.58
変換が異なるのはなぜですか?