aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorRichard M. Stallman1997-09-03 23:01:57 +0000
committerRichard M. Stallman1997-09-03 23:01:57 +0000
commitdca6c9144c707a8d23ca9c7cdad21554fce464e4 (patch)
treecc21fb64088cc3c942b9f52a5319f667d155bf1b /src/floatfns.c
parentbe417b22ba0628c2f99a4e32c7bf2027f8975196 (diff)
downloademacs-dca6c9144c707a8d23ca9c7cdad21554fce464e4.tar.gz
emacs-dca6c9144c707a8d23ca9c7cdad21554fce464e4.zip
(emacs_rint): Define this,
either as a function or as a macro for rint. (Fround, Ffround): Use emacs_rint, not rint directly.
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 29bdccf2989..6c8aece417d 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -25,7 +25,7 @@ Boston, MA 02111-1307, USA. */
25 25
26 Define HAVE_INVERSE_HYPERBOLIC if you have acosh, asinh, and atanh. 26 Define HAVE_INVERSE_HYPERBOLIC if you have acosh, asinh, and atanh.
27 Define HAVE_CBRT if you have cbrt. 27 Define HAVE_CBRT if you have cbrt.
28 Define HAVE_RINT if you have rint. 28 Define HAVE_RINT if you have a working rint.
29 If you don't define these, then the appropriate routines will be simulated. 29 If you don't define these, then the appropriate routines will be simulated.
30 30
31 Define HAVE_MATHERR if on a system supporting the SysV matherr callback. 31 Define HAVE_MATHERR if on a system supporting the SysV matherr callback.
@@ -826,9 +826,13 @@ round2 (i1, i2)
826 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1); 826 return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1);
827} 827}
828 828
829#ifndef HAVE_RINT 829/* The code uses emacs_rint, so that it works to undefine HAVE_RINT
830 if `rint' exists but does not work right. */
831#ifdef HAVE_RINT
832#define emacs_rint rint
833#else
830static double 834static double
831rint (d) 835emacs_rint (d)
832 double d; 836 double d;
833{ 837{
834 return floor (d + 0.5); 838 return floor (d + 0.5);
@@ -866,7 +870,7 @@ With optional DIVISOR, return the nearest integer to ARG/DIVISOR.")
866 (arg, divisor) 870 (arg, divisor)
867 Lisp_Object arg, divisor; 871 Lisp_Object arg, divisor;
868{ 872{
869 return rounding_driver (arg, divisor, rint, round2, "round"); 873 return rounding_driver (arg, divisor, emacs_rint, round2, "round");
870} 874}
871 875
872DEFUN ("truncate", Ftruncate, Struncate, 1, 2, 0, 876DEFUN ("truncate", Ftruncate, Struncate, 1, 2, 0,
@@ -931,12 +935,12 @@ DEFUN ("fround", Ffround, Sfround, 1, 1, 0,
931 register Lisp_Object arg; 935 register Lisp_Object arg;
932{ 936{
933 double d = extract_float (arg); 937 double d = extract_float (arg);
934 IN_FLOAT (d = rint (d), "fround", arg); 938 IN_FLOAT (d = emacs_rint (d), "fround", arg);
935 return make_float (d); 939 return make_float (d);
936} 940}
937 941
938DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0, 942DEFUN ("ftruncate", Fftruncate, Sftruncate, 1, 1, 0,
939 "Truncate a floating point number to an integral float value.\n\ 943 "Truncate a floating point number to an integral float value.\n\
940Rounds the value toward zero.") 944Rounds the value toward zero.")
941 (arg) 945 (arg)
942 register Lisp_Object arg; 946 register Lisp_Object arg;