将NSString转换为long值

时间:2017-01-31 15:38:49

标签: ios objective-c

将NSString转换为长值而不显示正确的数据。

@“86200054340607012013”​​integerValue或intValue显示 - 2147483647

@“86200054340607012013”​​longlongvalue显示 - 9223372036854775807

NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber * myNumber = [f numberFromString:@"86200054340607012013"];

显示 - 9223372036854775808

 NSNumberFormatter* formatter = [[NSNumberFormatter alloc] init];
 NSLog(@"======>%lu", [[formatter numberFromString:@"86200054340607012013"] unsignedLongValue]);

显示 - 12413078045768810496

转换此

的正确方法是什么?

0 个答案:

没有答案