[ create a new paste ] login | about

Link: http://codepad.org/86MlmNXU    [ raw code | output | fork ]

C++, pasted on Feb 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <cstdio>
#include <cmath>
using namespace std;

const int xl = 11;
double x[xl] = {179, 180, 181, 359, 721, -1, -179, -180, -359, -361, -721};
double y = 360;

int main() {
  for (int i = 0; i < xl; i++) {
    printf("fmod(%f, %f) = %f\n", x[i], y, fmod(x[i], y));
  }
  return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
fmod(179.000000, 360.000000) = 179.000000
fmod(180.000000, 360.000000) = 180.000000
fmod(181.000000, 360.000000) = 181.000000
fmod(359.000000, 360.000000) = 359.000000
fmod(721.000000, 360.000000) = 1.000000
fmod(-1.000000, 360.000000) = -1.000000
fmod(-179.000000, 360.000000) = -179.000000
fmod(-180.000000, 360.000000) = -180.000000
fmod(-359.000000, 360.000000) = -359.000000
fmod(-361.000000, 360.000000) = -1.000000
fmod(-721.000000, 360.000000) = -1.000000


Create a new paste based on this one


Comments: