pedometer application
I try to calculate a miles per hours. For this I write a code like this
mint=sec/60;
hour=mint/60;
mph=miles/hour;
nsstring *speed=[nsstring stringwithformat:@"%5.2f",mph];
[mph settext: speed];
I get a miles from this code
miles = (steps *steplength)/1500;
NSString *distance =[NSString stringWithFormat:@"%5.3f",TotalDistance];
[Miles1开发者_StackOverflow setText:distance];
And the error is shown me like this
miles per hour ans is (inf)
help me out
If the minute count is < 60, then hour
will be zero (if that's an integer division) and mph
becomes inf
.
精彩评论