8

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.

Piyo
  • 181
  • 1
  • 2
  • 9

1 Answers1

21

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?

Community
  • 1
  • 1
Omar Abdelhafith
  • 21,163
  • 5
  • 52
  • 56