开发者

NSNumberFormatter Problem

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 thr开发者_如何学运维ee 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];


  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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜