NSNumberFormatter 问题

发布于 2024-12-07 09:59:29 字数 683 浏览 7 评论 0原文

在我的应用程序中,我必须在活动人员之间共享金额,例如,我有 3 个人的名字,例如 RAM、RAJ、RAGHU,如果 RAM 在活动中投入的金额为 10.00,那么我会将其分配给三个人,例如 10.00/3 =3.333333,那么,

RAJ 必须向 RAM 付费-------------3.33
RAGHU 必须向 RAM 付费 ----------3.33

他从活动中的其他 2 个人那里得到的全部 6.66 这里缺少 0.1 我该如何解决这个问题 我正在使用 NumberStyle:NSNumberFormatterCurrencyStyle 如下所示

NSNumberFormatter *numberFormater = [[NSNumberFormatter alloc] init];
[numberFormater setLocale:[NSLocale currentLocale]];
[numberFormater setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString *str_num = [numberFormater stringFromNumber:[NSNumber numberWithDouble:3.333333]];
[numberFormater release];

IN my App i have to share the amount among the event people for Example i have 3 people names like RAM, RAJ, RAGHU ,if RAM put amount of 10.00 in event than i am dividing the among three people like 10.00/3=3.333333, Then,

RAJ has to pay to RAM-------------3.33
RAGHU has to pay to RAM -------3.33

over all he getting From other 2 people in the event 6.66
here 0.1 missing how can i solve this problem
i am using NumberStyle:NSNumberFormatterCurrencyStyle like below

NSNumberFormatter *numberFormater = [[NSNumberFormatter alloc] init];
[numberFormater setLocale:[NSLocale currentLocale]];
[numberFormater setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString *str_num = [numberFormater stringFromNumber:[NSNumber numberWithDouble:3.333333]];
[numberFormater release];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花桑 2024-12-14 09:59:29
  float invoice= 10.15;
  int num_people = 3; // sample people
  float num_to_add;
  float piece_pie;
  // now just add num_to_add to your invoice then divide by num_people
  num_to_add=num_people*.01;
  invoice=invoice+num_to_add;
  piece_pie = invoice/num_people;
  float invoice= 10.15;
  int num_people = 3; // sample people
  float num_to_add;
  float piece_pie;
  // now just add num_to_add to your invoice then divide by num_people
  num_to_add=num_people*.01;
  invoice=invoice+num_to_add;
  piece_pie = invoice/num_people;
∞梦里开花 2024-12-14 09:59:29

为什么不从 10 中减去 RAM 的份额呢? 10 - 3.33 = 6.67。

Why don't you subtract RAM's share from 10? 10 - 3.33 = 6.67.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文