C++,
pasted
on Feb 1:
|
|
#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:
|
|
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
|
|