Using mod operator in iOS app

Jerry picture Jerry · Sep 17, 2010 · Viewed 33.3k times · Source

I have an NSTimeInterval that is stored as a double. I would like to get the amount of minutes that are inide of the second value using the % operator.

minutes = secondValue % 60;

where minutes is declared as double minutes

The result is that XCode says "Invalid operands to binary %"

Thoughts?

Answer

Carl Norum picture Carl Norum · Sep 17, 2010

From the C standard, section 6.5.5 Multiplicative operators, paragraph 2:

The operands of the % operator shall have integer type.