Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

丢失精度 #2

Open
dongpeng66 opened this issue Jan 5, 2018 · 1 comment
Open

丢失精度 #2

dongpeng66 opened this issue Jan 5, 2018 · 1 comment

Comments

@dongpeng66
Copy link

我请大神一个问题 为什么这个
[self.label3 pp_fromNumber:0 toNumber:148372.82 duration:1.0f format:^NSString *(CGFloat number) {
NSNumberFormatter *formatter = [NSNumberFormatter new];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
formatter.positiveFormat = @"###,##0.00";
NSNumber *amountNumber = [NSNumber numberWithFloat:number];
return [NSString stringWithFormat:@"%@",[formatter stringFromNumber:amountNumber]];
}];
这样显示出来的数字是 148372.81 丢失了一个精度 0.01

@isdotjim
Copy link

搭个车...
想邀请Repo作者来w3c.group创建项目的对应小组。w3c.group是类似知识星球的社群工具,小组可设置为付费且有赞助功能,同时也是一个区块链主导的创作者社区。这是相关介绍:
http://t.cn/Ai1vLcCU
http://t.cn/Ai1vLcCG
http://t.cn/Ai1vLcCA

@VictorZHV
Copy link

[NSNumber numberWithFloat:number]改成[NSNumber numberWithDouble:number]就行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants