Mercurial > hg > octave-nkf
diff liboctave/lo-mappers.cc @ 10436:00219bdd2d17
implement built-in rem and mod
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 23 Mar 2010 13:01:34 +0100 |
parents | 479cc8a0a846 |
children | 20ce1bea653d |
line wrap: on
line diff
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -131,6 +131,16 @@ } double +mod (double x, double y) +{ + if (y == 0) + return x; + + double r = fmod (x, y); + return ((r < 0) != (y < 0)) ? y+r : r; +} + +double xlog2 (double x) { #if defined (HAVE_LOG2) @@ -435,6 +445,16 @@ } float +mod (float x, float y) +{ + if (y == 0) + return x; + + float r = fmodf (x, y); + return ((r < 0) != (y < 0)) ? y+r : r; +} + +float xlog2 (float x) { #if defined (HAVE_LOG2)