在我的应用程序中,我必须在事件人之间共享数量--例如,我有三个人的名字,如RAM、RAJ、RAGHU,如果内存在事件中的数量是10.00,那么我就把它分成三个人,比如10.00/3=3.333333,
RAJ必须向RAM支付
RAGHU必须支付RAM -3.33
总之,他从事件中的其他两个人那里得到了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];发布于 2011-09-29 04:53:46
你为什么不把RAM的份额从10? 10-3.33= 6.67减去。
发布于 2011-09-29 05:07:48
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;https://stackoverflow.com/questions/7592529
复制相似问题