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];
Why don't you subtract RAM's share from 10? 10 - 3.33 = 6.67.
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.