aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorKarl Heuer1994-09-27 03:01:14 +0000
committerKarl Heuer1994-09-27 03:01:14 +0000
commit207a45c169e22fe776a89a7289f717c0a8423642 (patch)
tree059b546126292aa81fd046dab2ad7a7d8dd2be44 /src/floatfns.c
parent7650760ef8fa2f89739cb235e09f172073f1c902 (diff)
downloademacs-207a45c169e22fe776a89a7289f717c0a8423642.tar.gz
emacs-207a45c169e22fe776a89a7289f717c0a8423642.zip
(extract_float, Fexpt, Fabs, Ffloat, Fceiling, Ffloor, Fround, Ftruncate): Use
type test macros.
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 6d74477c14a..134332b9861 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -217,7 +217,7 @@ extract_float (num)
217{ 217{
218 CHECK_NUMBER_OR_FLOAT (num, 0); 218 CHECK_NUMBER_OR_FLOAT (num, 0);
219 219
220 if (XTYPE (num) == Lisp_Float) 220 if (FLOATP (num))
221 return XFLOAT (num)->data; 221 return XFLOAT (num)->data;
222 return (double) XINT (num); 222 return (double) XINT (num);
223} 223}
@@ -444,8 +444,8 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
444 444
445 CHECK_NUMBER_OR_FLOAT (arg1, 0); 445 CHECK_NUMBER_OR_FLOAT (arg1, 0);
446 CHECK_NUMBER_OR_FLOAT (arg2, 0); 446 CHECK_NUMBER_OR_FLOAT (arg2, 0);
447 if (XTYPE (arg1) == Lisp_Int /* common lisp spec */ 447 if (INTEGERP (arg1) /* common lisp spec */
448 && XTYPE (arg2) == Lisp_Int) /* don't promote, if both are ints */ 448 && INTEGERP (arg2)) /* don't promote, if both are ints */
449 { /* this can be improved by pre-calculating */ 449 { /* this can be improved by pre-calculating */
450 int acc, x, y; /* some binary powers of x then accumulating */ 450 int acc, x, y; /* some binary powers of x then accumulating */
451 Lisp_Object val; 451 Lisp_Object val;
@@ -476,8 +476,8 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
476 XSET (val, Lisp_Int, acc); 476 XSET (val, Lisp_Int, acc);
477 return val; 477 return val;
478 } 478 }
479 f1 = (XTYPE (arg1) == Lisp_Float) ? XFLOAT (arg1)->data : XINT (arg1); 479 f1 = FLOATP (arg1) ? XFLOAT (arg1)->data : XINT (arg1);
480 f2 = (XTYPE (arg2) == Lisp_Float) ? XFLOAT (arg2)->data : XINT (arg2); 480 f2 = FLOATP (arg2) ? XFLOAT (arg2)->data : XINT (arg2);
481 /* Really should check for overflow, too */ 481 /* Really should check for overflow, too */
482 if (f1 == 0.0 && f2 == 0.0) 482 if (f1 == 0.0 && f2 == 0.0)
483 f1 = 1.0; 483 f1 = 1.0;
@@ -645,7 +645,7 @@ DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
645{ 645{
646 CHECK_NUMBER_OR_FLOAT (arg, 0); 646 CHECK_NUMBER_OR_FLOAT (arg, 0);
647 647
648 if (XTYPE (arg) == Lisp_Float) 648 if (FLOATP (arg))
649 IN_FLOAT (arg = make_float (fabs (XFLOAT (arg)->data)), "abs", arg); 649 IN_FLOAT (arg = make_float (fabs (XFLOAT (arg)->data)), "abs", arg);
650 else if (XINT (arg) < 0) 650 else if (XINT (arg) < 0)
651 XSETINT (arg, - XFASTINT (arg)); 651 XSETINT (arg, - XFASTINT (arg));
@@ -660,7 +660,7 @@ DEFUN ("float", Ffloat, Sfloat, 1, 1, 0,
660{ 660{
661 CHECK_NUMBER_OR_FLOAT (arg, 0); 661 CHECK_NUMBER_OR_FLOAT (arg, 0);
662 662
663 if (XTYPE (arg) == Lisp_Int) 663 if (INTEGERP (arg))
664 return make_float ((double) XINT (arg)); 664 return make_float ((double) XINT (arg));
665 else /* give 'em the same float back */ 665 else /* give 'em the same float back */
666 return arg; 666 return arg;
@@ -722,7 +722,7 @@ DEFUN ("ceiling", Fceiling, Sceiling, 1, 1, 0,
722{ 722{
723 CHECK_NUMBER_OR_FLOAT (arg, 0); 723 CHECK_NUMBER_OR_FLOAT (arg, 0);
724 724
725 if (XTYPE (arg) == Lisp_Float) 725 if (FLOATP (arg))
726 { 726 {
727 double d; 727 double d;
728 728
@@ -751,13 +751,12 @@ With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR.")
751 CHECK_NUMBER_OR_FLOAT (divisor, 1); 751 CHECK_NUMBER_OR_FLOAT (divisor, 1);
752 752
753#ifdef LISP_FLOAT_TYPE 753#ifdef LISP_FLOAT_TYPE
754 if (XTYPE (arg) == Lisp_Float || XTYPE (divisor) == Lisp_Float) 754 if (FLOATP (arg) || FLOATP (divisor))
755 { 755 {
756 double f1, f2; 756 double f1, f2;
757 757
758 f1 = XTYPE (arg) == Lisp_Float ? XFLOAT (arg)->data : XINT (arg); 758 f1 = FLOATP (arg) ? XFLOAT (arg)->data : XINT (arg);
759 f2 = (XTYPE (divisor) == Lisp_Float 759 f2 = (FLOATP (divisor) ? XFLOAT (divisor)->data : XINT (divisor));
760 ? XFLOAT (divisor)->data : XINT (divisor));
761 if (f2 == 0) 760 if (f2 == 0)
762 Fsignal (Qarith_error, Qnil); 761 Fsignal (Qarith_error, Qnil);
763 762
@@ -784,7 +783,7 @@ With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR.")
784 } 783 }
785 784
786#ifdef LISP_FLOAT_TYPE 785#ifdef LISP_FLOAT_TYPE
787 if (XTYPE (arg) == Lisp_Float) 786 if (FLOATP (arg))
788 { 787 {
789 double d; 788 double d;
790 IN_FLOAT (d = floor (XFLOAT (arg)->data), "floor", arg); 789 IN_FLOAT (d = floor (XFLOAT (arg)->data), "floor", arg);
@@ -804,7 +803,7 @@ DEFUN ("round", Fround, Sround, 1, 1, 0,
804{ 803{
805 CHECK_NUMBER_OR_FLOAT (arg, 0); 804 CHECK_NUMBER_OR_FLOAT (arg, 0);
806 805
807 if (XTYPE (arg) == Lisp_Float) 806 if (FLOATP (arg))
808 { 807 {
809 double d; 808 double d;
810 809
@@ -824,7 +823,7 @@ Rounds the value toward zero.")
824{ 823{
825 CHECK_NUMBER_OR_FLOAT (arg, 0); 824 CHECK_NUMBER_OR_FLOAT (arg, 0);
826 825
827 if (XTYPE (arg) == Lisp_Float) 826 if (FLOATP (arg))
828 { 827 {
829 double d; 828 double d;
830 829