Skip to content

Instantly share code, notes, and snippets.

@boredzo
Created January 28, 2014 02:04
Show Gist options
  • Save boredzo/8661176 to your computer and use it in GitHub Desktop.
Save boredzo/8661176 to your computer and use it in GitHub Desktop.
The difference between fmod and remainder
NSTimeInterval days = 0.0;
NSTimeInterval hours = 1.0;
NSTimeInterval minutes = 49.0;
NSTimeInterval seconds = 6.215;
NSTimeInterval interval =
days * 3600.0 * 24.0
+ hours * 3600.0
+ minutes * 60.0
+ seconds * 1.0;
NSLog(@"%f", fmod(interval / 60.0, 60.0)); // 49.103583
NSLog(@"%f", remainder(interval / 60.0, 60.0)); // -10.896417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment