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.
int remainingSeconds = scratch % 60;
The error said "invalid operands to binary expression" point at % Help please.
modulus is used on integers, so for your code to work do the following
int remainingSeconds = (int)scratch % 60;
To use modulus on floats use fmod
int remainingSeconds = fmod(scratch, 60);
check answer here How to make a modulo operation in objective-c / cocoa touch?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With