comparison between point and integer
- by LawVS
Right, basically I want to add two numbers together. It's for a working hours calculator and I've included parameters for a night shift scenario as an if statement. However, it now mucks up the day shift pattern. So I want to sort out that if the start time is below 12, then it'll revert to the original equation shown in the code instead of the if statement.
-(IBAction)done:(id)sender {
int result = [finishHours.text intValue] - [startHours.text intValue];
totalHours.text = [NSString stringWithFormat:@"%d", result];
if (result < 0) {
totalHours.text = [NSString stringWithFormat:@"%d", result * -1];
}
if (result < 12) {
totalHours.text = [NSString stringWithFormat:@"%d", result + 24];
}
if (startHours < 12) {
totalHours.text = [NSString stringWithFormat:@"%d", result - 24];
}