Skip to content

Instantly share code, notes, and snippets.

@gregheo
Created July 27, 2016 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregheo/63573aa24c4b41b2e2218e545adc67e7 to your computer and use it in GitHub Desktop.
Save gregheo/63573aa24c4b41b2e2218e545adc67e7 to your computer and use it in GitHub Desktop.
remainder()
#include <stdio.h>
#include <math.h>
int main(void) {
double const number = 8.0;
for (double i = number; i < number * 2 + 1; ++i) {
printf("remainder(%2.0f, %2.0f) = %2.0f\n", i, number, remainder(i, number));
}
return 0;
}
/* output:
remainder( 8, 8) = 0
remainder( 9, 8) = 1
remainder(10, 8) = 2
remainder(11, 8) = 3
remainder(12, 8) = -4
remainder(13, 8) = -3
remainder(14, 8) = -2
remainder(15, 8) = -1
remainder(16, 8) = 0
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment