Mercurial > hg > octave-lyh
changeset 10459:20ce1bea653d
use round and trunc from gnulib where possible
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 25 Mar 2010 11:45:10 +0100 |
parents | 9684b3c3b417 |
children | 4975d63bb2df |
files | ChangeLog bootstrap.conf liboctave/ChangeLog liboctave/lo-mappers.cc |
diffstat | 4 files changed, 21 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-03-25 Jaroslav Hajek <highegg@gmail.com> + + * bootstrap.conf: Include roundf, trunc, truncf. + 2010-03-24 John W. Eaton <jwe@octave.org> * configure.ac (AC_INIT): Version is now 3.3.51.
--- a/bootstrap.conf +++ b/bootstrap.conf @@ -56,6 +56,9 @@ unlink vsnprintf round + roundf + trunc + truncf " # Additional xgettext options to use. Use "\\\newline" to break lines.
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,13 @@ +2010-03-25 Jaroslav Hajek <highegg@gmail.com> + + * lo-mappers.cc + (fix (double)): Forward to gnulib::trunc. + (fix (float)): Forward to gnulib::truncf. + (xround (double)): Forward to gnulib::round. + (xround (float)): Forward to gnulib::roundf. + (xtrunc (double)): Forward to gnulib::trunc. + (xtrunc (float)): Forward to gnulib::truncf. + 2010-03-25 David Grundberg <davidg@cs.umu.se> * oct-time.h (octave_time): Revert ::modf to std::modf again now
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -54,7 +54,7 @@ double fix (double x) { - return x > 0 ? floor (x) : ceil (x); + return gnulib::trunc (x); } double @@ -72,38 +72,13 @@ double xround (double x) { -#if defined (HAVE_ROUND) return gnulib::round (x); -#else - if (x >= 0) - { - double y = floor (x); - - if ((x - y) >= 0.5) - y += 1.0; - - return y; - } - else - { - double y = ceil (x); - - if ((y - x) >= 0.5) - y -= 1.0; - - return y; - } -#endif } double xtrunc (double x) { -#if defined (HAVE_TRUNC) - return trunc (x); -#else - return x > 0 ? floor (x) : ceil (x); -#endif + return gnulib::trunc (x); } double @@ -368,7 +343,7 @@ float fix (float x) { - return x > 0 ? floor (x) : ceil (x); + return gnulib::truncf (x); } float @@ -386,38 +361,13 @@ float xround (float x) { -#if defined (HAVE_ROUND) return gnulib::round (x); -#else - if (x >= 0) - { - float y = floor (x); - - if ((x - y) >= 0.5) - y += 1.0; - - return y; - } - else - { - float y = ceil (x); - - if ((y - x) >= 0.5) - y -= 1.0; - - return y; - } -#endif } float xtrunc (float x) { -#if defined (HAVE_TRUNC) - return trunc (x); -#else - return x > 0 ? floor (x) : ceil (x); -#endif + return gnulib::truncf (x); } float