Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
r_mod.c
Go to the documentation of this file.00001 #include "f2c.h"
00002
00003 #ifdef KR_headers
00004 #ifdef IEEE_drem
00005 double drem();
00006 #else
00007 double floor();
00008 #endif
00009 double r_mod(x,y) real *x, *y;
00010 #else
00011 #ifdef IEEE_drem
00012 double drem(double, double);
00013 #else
00014 #undef abs
00015 #include "mathh.h"
00016 #endif
00017 double r_mod(real *x, real *y)
00018 #endif
00019 {
00020 #ifdef IEEE_drem
00021 double xa, ya, z;
00022 if ((ya = *y) < 0.)
00023 ya = -ya;
00024 z = drem(xa = *x, ya);
00025 if (xa > 0) {
00026 if (z < 0)
00027 z += ya;
00028 }
00029 else if (z > 0)
00030 z -= ya;
00031 return z;
00032 #else
00033 double quotient;
00034 if( (quotient = (double)*x / *y) >= 0)
00035 quotient = floor(quotient);
00036 else
00037 quotient = -floor(-quotient);
00038 return(*x - (*y) * quotient );
00039 #endif
00040 }