我有这个示例代码:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSString *numberString = @"9.2";
NSNumber *number = [formatter numberFromString:numberString];
NSLog(@"String: %@, Number: %@", numberString, number);
打印的结果是:
String: 9.2, Number: 9.199999999999999
我不明白为什么会发生这种情况。我错过了一个设置吗?