guys, I have some very little floats and I want to round it up to first not nil value. For example:
float toRound = 0.000002125231553;
toRound = //Operations//;
toRound == 0.000002;
Have you any ideas?
guys, I have some very little floats and I want to round it up to first not nil value. For example:
float toRound = 0.000002125231553;
toRound = //Operations//;
toRound == 0.000002;
Have you any ideas?
perhaps not the best approach. but it does what you want ;)
float s = 0.000322333123;
BOOL exit = 0;
NSString *x = [NSString stringWithFormat:@"%f", s];
for (int i = 0; i <= [x length]; i++) {
NSString *t = [x substringToIndex:i];
if ([t floatValue] == 0 || exit == 1) {
;;
}
else {
exit = 1;
s = [t floatValue];
}
}
NSLog(@"round: %f", s);
Log: round: 0.0003