views:

125

answers:

2

hi, i need to show a number to a user : 1.96666777 (timeHour)

moduloformat = [NSString stringWithFormat:@"%0.0f hours ",timeHour];

but it is rounding off the number automaticly. It gives "2" and i want to show "1" i could use a NSrange and take the first number but i wanna know how to deal with this. Thanks!!

+3  A: 
moduloformat = [NSString stringWithFormat:@"%0.0f hours ",floor( timeHour )];
drawnonward
A: 

Easiest to just cast the float to an int. When you do that the decimal places get chopped off and no rounding occurs.

moduloformat = [NSString stringWithFormat:@"%i hours ", (int)timeHour];
regulus6633