Pradeep
Pradeep

Reputation: 179

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 setText:distance];

And the error is shown me like this

miles per hour ans is (inf)

help me out

Upvotes: 0

Views: 585

Answers (1)

Mau
Mau

Reputation: 14478

If the minute count is < 60, then hour will be zero (if that's an integer division) and mph becomes inf.

Upvotes: 1

Related Questions