codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <math.h> float ZZZ_fmodf(float a, float N) { //assert(N>0); // 10.8 mod 2, floor (5.4) = 5 ... 10.8 - 5*2 = .8 YES // -10.8 mod 2, floor (-5.4) = -6 ... -10.8 - (-6*2) = 1.2 YES float ret = a - N * floor (a / N); printf("%f ZZZ_fmodf %f = %f \n", a, N, ret); return ret; } int main (char* argc, char** argv) { float x = fmodf(-10.2f, 2.0f); printf ("fmodf(-10.2f, 2.0f) = %f == FAIL! \n", x); x = ZZZ_fmodf(10.2f, 2.0f); x = ZZZ_fmodf(10.2f, -2.0f); x = ZZZ_fmodf(-10.2f, 2.0f); x = ZZZ_fmodf(-10.2f, -2.0f); return 0; }
Private
[
?
]
Run code
Submit