Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(NSString *)stringFromNumber:(NSNumber *)number
- {
- NSLog(@"Input:---%@",number);
- NSNumberFormatter *numFormatter = [[[NSNumberFormatter alloc] init] autorelease];
- [numFormatter setMaximumFractionDigits:5];
- [numFormatter setMinimumFractionDigits:2];
- //[numFormatter setExponentSymbol:@"e"];
- NSString *str_num = [numFormatter stringFromNumber:number];
- NSLog(@"Output:---%@",str_num);
- return str_num;
- }
- in console i am getting like below
- Input:---2.940000057220459
- Output:---2.94
- Input:---2940.000057220459
- Output:---2940.00006
- Input:---2.940000057220459e-15
- Output:---.00
- Input:---2.940000057220459e-12
- Output:---.00
- Input:---2.940000057220459e-09
- Output:---.00
- Input:---2.940000057220459e-06
- Output:---.00
- Input:---0.002940000057220459
- Output:---.00294
- but i need like below for above inputs (order)
- ---2.94
- ---2940
- ---2.94e-15
- ---2.94e-12
- ---2.94e-6
- ---2.94e-9
- ---0.00294
Advertisement
Add Comment
Please, Sign In to add comment