comparison src/floatfns.c @ 5581:56144c8593a8

Mechanically change INT to FIXNUM in our sources. src/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT (where it refers to non-bignum Lisp integers) to FIXNUM in our sources. Done for the following functions, enums, and macros: Lisp_Type_Int_Even, Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(), XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(), EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT. The EMACS_INT typedef was not changed, it does not describe non-bignum Lisp integers. Script that did the change available in http://mid.gmane.org/20067.17650.181273.12014@parhasard.net . modules/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers. See the src/ChangeLog entry for more details. man/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> * internals/internals.texi (How Lisp Objects Are Represented in C): * internals/internals.texi (Integers and Characters): Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 09 Oct 2011 09:51:57 +0100
parents 6506fcb40fcf
children be31f7878b0d
comparison
equal deleted inserted replaced
5580:a0e81357194e 5581:56144c8593a8
130 bignum_set_double (scratch_bignum, x); 130 bignum_set_double (scratch_bignum, x);
131 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 131 return Fcanonicalize_number (make_bignum_bg (scratch_bignum));
132 #else 132 #else
133 REGISTER EMACS_INT result = (EMACS_INT) x; 133 REGISTER EMACS_INT result = (EMACS_INT) x;
134 134
135 if (result > EMACS_INT_MAX || result < EMACS_INT_MIN) 135 if (result > MOST_POSITIVE_FIXNUM || result < MOST_NEGATIVE_FIXNUM)
136 { 136 {
137 if (!UNBOUNDP (num2)) 137 if (!UNBOUNDP (num2))
138 range_error2 (name, num, num2); 138 range_error2 (name, num, num2);
139 else 139 else
140 range_error (name, num); 140 range_error (name, num);
141 } 141 }
142 return make_int (result); 142 return make_fixnum (result);
143 #endif /* HAVE_BIGNUM */ 143 #endif /* HAVE_BIGNUM */
144 } 144 }
145 145
146 146
147 static void 147 static void
201 extract_float (Lisp_Object num) 201 extract_float (Lisp_Object num)
202 { 202 {
203 if (FLOATP (num)) 203 if (FLOATP (num))
204 return XFLOAT_DATA (num); 204 return XFLOAT_DATA (num);
205 205
206 if (INTP (num)) 206 if (FIXNUMP (num))
207 return (double) XINT (num); 207 return (double) XFIXNUM (num);
208 208
209 #ifdef HAVE_BIGNUM 209 #ifdef HAVE_BIGNUM
210 if (BIGNUMP (num)) 210 if (BIGNUMP (num))
211 return bignum_to_double (XBIGNUM_DATA (num)); 211 return bignum_to_double (XBIGNUM_DATA (num));
212 #endif 212 #endif
442 Return the exponential NUMBER1 ** NUMBER2. 442 Return the exponential NUMBER1 ** NUMBER2.
443 */ 443 */
444 (number1, number2)) 444 (number1, number2))
445 { 445 {
446 #ifdef HAVE_BIGNUM 446 #ifdef HAVE_BIGNUM
447 if (INTEGERP (number1) && INTP (number2)) 447 if (INTEGERP (number1) && FIXNUMP (number2))
448 { 448 {
449 if (INTP (number1)) 449 if (FIXNUMP (number1))
450 { 450 {
451 bignum_set_long (scratch_bignum2, XREALINT (number1)); 451 bignum_set_long (scratch_bignum2, XREALFIXNUM (number1));
452 bignum_pow (scratch_bignum, scratch_bignum2, XREALINT (number2)); 452 bignum_pow (scratch_bignum, scratch_bignum2, XREALFIXNUM (number2));
453 } 453 }
454 else 454 else
455 bignum_pow (scratch_bignum, XBIGNUM_DATA (number1), 455 bignum_pow (scratch_bignum, XBIGNUM_DATA (number1),
456 XREALINT (number2)); 456 XREALFIXNUM (number2));
457 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 457 return Fcanonicalize_number (make_bignum_bg (scratch_bignum));
458 } 458 }
459 #endif 459 #endif
460 460
461 if (INTP (number1) && /* common lisp spec */ 461 if (FIXNUMP (number1) && /* common lisp spec */
462 INTP (number2)) /* don't promote, if both are ints */ 462 FIXNUMP (number2)) /* don't promote, if both are ints */
463 { 463 {
464 EMACS_INT retval; 464 EMACS_INT retval;
465 EMACS_INT x = XINT (number1); 465 EMACS_INT x = XFIXNUM (number1);
466 EMACS_INT y = XINT (number2); 466 EMACS_INT y = XFIXNUM (number2);
467 467
468 if (y < 0) 468 if (y < 0)
469 { 469 {
470 if (x == 1) 470 if (x == 1)
471 retval = 1; 471 retval = 1;
483 retval *= x; 483 retval *= x;
484 x *= x; 484 x *= x;
485 y = (EMACS_UINT) y >> 1; 485 y = (EMACS_UINT) y >> 1;
486 } 486 }
487 } 487 }
488 return make_int (retval); 488 return make_fixnum (retval);
489 } 489 }
490 490
491 #if defined(HAVE_BIGFLOAT) && defined(bigfloat_pow) 491 #if defined(HAVE_BIGFLOAT) && defined(bigfloat_pow)
492 if (BIGFLOATP (number1) && INTEGERP (number2)) 492 if (BIGFLOATP (number1) && INTEGERP (number2))
493 { 493 {
709 IN_FLOAT (number = make_float (fabs (XFLOAT_DATA (number))), 709 IN_FLOAT (number = make_float (fabs (XFLOAT_DATA (number))),
710 "abs", number); 710 "abs", number);
711 return number; 711 return number;
712 } 712 }
713 713
714 if (INTP (number)) 714 if (FIXNUMP (number))
715 #ifdef HAVE_BIGNUM 715 #ifdef HAVE_BIGNUM
716 /* The most negative Lisp fixnum will overflow */ 716 /* The most negative Lisp fixnum will overflow */
717 return (XINT (number) >= 0) ? number : make_integer (- XINT (number)); 717 return (XFIXNUM (number) >= 0) ? number : make_integer (- XFIXNUM (number));
718 #else 718 #else
719 return (XINT (number) >= 0) ? number : make_int (- XINT (number)); 719 return (XFIXNUM (number) >= 0) ? number : make_fixnum (- XFIXNUM (number));
720 #endif 720 #endif
721 721
722 #ifdef HAVE_BIGNUM 722 #ifdef HAVE_BIGNUM
723 if (BIGNUMP (number)) 723 if (BIGNUMP (number))
724 { 724 {
756 DEFUN ("float", Ffloat, 1, 1, 0, /* 756 DEFUN ("float", Ffloat, 1, 1, 0, /*
757 Return the floating point number numerically equal to NUMBER. 757 Return the floating point number numerically equal to NUMBER.
758 */ 758 */
759 (number)) 759 (number))
760 { 760 {
761 if (INTP (number)) 761 if (FIXNUMP (number))
762 return make_float ((double) XINT (number)); 762 return make_float ((double) XFIXNUM (number));
763 763
764 #ifdef HAVE_BIGNUM 764 #ifdef HAVE_BIGNUM
765 if (BIGNUMP (number)) 765 if (BIGNUMP (number))
766 { 766 {
767 #ifdef HAVE_BIGFLOAT 767 #ifdef HAVE_BIGFLOAT
802 (number)) 802 (number))
803 { 803 {
804 double f = extract_float (number); 804 double f = extract_float (number);
805 805
806 if (f == 0.0) 806 if (f == 0.0)
807 return make_int (EMACS_INT_MIN); 807 return make_fixnum (MOST_NEGATIVE_FIXNUM);
808 #ifdef HAVE_LOGB 808 #ifdef HAVE_LOGB
809 { 809 {
810 Lisp_Object val; 810 Lisp_Object val;
811 IN_FLOAT (val = make_int ((EMACS_INT) logb (f)), "logb", number); 811 IN_FLOAT (val = make_fixnum ((EMACS_INT) logb (f)), "logb", number);
812 return val; 812 return val;
813 } 813 }
814 #else 814 #else
815 #ifdef HAVE_FREXP 815 #ifdef HAVE_FREXP
816 { 816 {
817 int exqp; 817 int exqp;
818 IN_FLOAT (frexp (f, &exqp), "logb", number); 818 IN_FLOAT (frexp (f, &exqp), "logb", number);
819 return make_int (exqp - 1); 819 return make_fixnum (exqp - 1);
820 } 820 }
821 #else 821 #else
822 { 822 {
823 int i; 823 int i;
824 double d; 824 double d;
838 for (i = 1, d = 2.0; d * d <= f; i += i) 838 for (i = 1, d = 2.0; d * d <= f; i += i)
839 d *= d; 839 d *= d;
840 f /= d; 840 f /= d;
841 val += i; 841 val += i;
842 } 842 }
843 return make_int (val); 843 return make_fixnum (val);
844 } 844 }
845 #endif /* ! HAVE_FREXP */ 845 #endif /* ! HAVE_FREXP */
846 #endif /* ! HAVE_LOGB */ 846 #endif /* ! HAVE_LOGB */
847 } 847 }
848 848
893 { \ 893 { \
894 /* The promote_args call if number types are available \ 894 /* The promote_args call if number types are available \
895 does these conversions, we do them too for symmetry: */\ 895 does these conversions, we do them too for symmetry: */\
896 if (CHARP (number)) \ 896 if (CHARP (number)) \
897 { \ 897 { \
898 number = make_int (XCHAR (number)); \ 898 number = make_fixnum (XCHAR (number)); \
899 } \ 899 } \
900 else if (MARKERP (number)) \ 900 else if (MARKERP (number)) \
901 { \ 901 { \
902 number = make_int (marker_position (number)); \ 902 number = make_fixnum (marker_position (number)); \
903 } \ 903 } \
904 \ 904 \
905 if (CHARP (divisor)) \ 905 if (CHARP (divisor)) \
906 { \ 906 { \
907 divisor = make_int (XCHAR (divisor)); \ 907 divisor = make_fixnum (XCHAR (divisor)); \
908 } \ 908 } \
909 else if (MARKERP (divisor)) \ 909 else if (MARKERP (divisor)) \
910 { \ 910 { \
911 divisor = make_int (marker_position (divisor)); \ 911 divisor = make_fixnum (marker_position (divisor)); \
912 } \ 912 } \
913 \ 913 \
914 CHECK_INT_OR_FLOAT (divisor); \ 914 CHECK_FIXNUM_OR_FLOAT (divisor); \
915 if (INTP (number) && INTP (divisor)) \ 915 if (FIXNUMP (number) && FIXNUMP (divisor)) \
916 { \ 916 { \
917 return conversion##_two_fixnum (number, divisor, \ 917 return conversion##_two_fixnum (number, divisor, \
918 return_float); \ 918 return_float); \
919 } \ 919 } \
920 else \ 920 else \
986 markers as equivalent to ints. This block does the same for 986 markers as equivalent to ints. This block does the same for
987 single-argument calls. */ 987 single-argument calls. */
988 #define MAYBE_CHAR_OR_MARKER(conversion) do { \ 988 #define MAYBE_CHAR_OR_MARKER(conversion) do { \
989 if (CHARP (number)) \ 989 if (CHARP (number)) \
990 { \ 990 { \
991 return conversion##_one_mundane_arg (make_int (XCHAR (number)), \ 991 return conversion##_one_mundane_arg (make_fixnum (XCHAR (number)), \
992 divisor, return_float); \ 992 divisor, return_float); \
993 } \ 993 } \
994 \ 994 \
995 if (MARKERP (number)) \ 995 if (MARKERP (number)) \
996 { \ 996 { \
997 return conversion##_one_mundane_arg (make_int \ 997 return conversion##_one_mundane_arg (make_fixnum \
998 (marker_position(number)), \ 998 (marker_position(number)), \
999 divisor, return_float); \ 999 divisor, return_float); \
1000 } \ 1000 } \
1001 } while (0) 1001 } while (0)
1002 1002
1005 1005
1006 static Lisp_Object 1006 static Lisp_Object
1007 ceiling_two_fixnum (Lisp_Object number, Lisp_Object divisor, 1007 ceiling_two_fixnum (Lisp_Object number, Lisp_Object divisor,
1008 int return_float) 1008 int return_float)
1009 { 1009 {
1010 EMACS_INT i1 = XREALINT (number); 1010 EMACS_INT i1 = XREALFIXNUM (number);
1011 EMACS_INT i2 = XREALINT (divisor); 1011 EMACS_INT i2 = XREALFIXNUM (divisor);
1012 EMACS_INT i3 = 0, i4 = 0; 1012 EMACS_INT i3 = 0, i4 = 0;
1013 1013
1014 if (i2 == 0) 1014 if (i2 == 0)
1015 return arith_error2 ("ceiling", number, divisor); 1015 return arith_error2 ("ceiling", number, divisor);
1016 1016
1060 1060
1061 i4 = i1 - (i3 * i2); 1061 i4 = i1 - (i3 * i2);
1062 1062
1063 if (!return_float) 1063 if (!return_float)
1064 { 1064 {
1065 return values2 (make_int (i3), make_int (i4)); 1065 return values2 (make_fixnum (i3), make_fixnum (i4));
1066 } 1066 }
1067 1067
1068 return values2 (make_float ((double)i3), 1068 return values2 (make_float ((double)i3),
1069 make_int (i4)); 1069 make_fixnum (i4));
1070 } 1070 }
1071 1071
1072 #ifdef HAVE_BIGNUM 1072 #ifdef HAVE_BIGNUM
1073 static Lisp_Object 1073 static Lisp_Object
1074 ceiling_two_bignum (Lisp_Object number, Lisp_Object divisor, 1074 ceiling_two_bignum (Lisp_Object number, Lisp_Object divisor,
1158 { 1158 {
1159 #ifdef HAVE_BIGNUM 1159 #ifdef HAVE_BIGNUM
1160 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat); 1160 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat);
1161 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1161 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1162 #else 1162 #else
1163 res0 = make_int ((EMACS_INT) bigfloat_to_long (scratch_bigfloat)); 1163 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (scratch_bigfloat));
1164 #endif /* HAVE_BIGNUM */ 1164 #endif /* HAVE_BIGNUM */
1165 } 1165 }
1166 1166
1167 bigfloat_mul (scratch_bigfloat, scratch_bigfloat, XBIGFLOAT_DATA (divisor)); 1167 bigfloat_mul (scratch_bigfloat, scratch_bigfloat, XBIGFLOAT_DATA (divisor));
1168 bigfloat_sub (scratch_bigfloat, XBIGFLOAT_DATA (number), scratch_bigfloat); 1168 bigfloat_sub (scratch_bigfloat, XBIGFLOAT_DATA (number), scratch_bigfloat);
1218 { 1218 {
1219 #ifdef HAVE_BIGNUM 1219 #ifdef HAVE_BIGNUM
1220 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat); 1220 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat);
1221 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1221 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1222 #else 1222 #else
1223 res0 = make_int ((EMACS_INT) bigfloat_to_long (scratch_bigfloat)); 1223 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (scratch_bigfloat));
1224 #endif /* HAVE_BIGNUM */ 1224 #endif /* HAVE_BIGNUM */
1225 } 1225 }
1226 1226
1227 bigfloat_sub (scratch_bigfloat2, XBIGFLOAT_DATA (number), scratch_bigfloat); 1227 bigfloat_sub (scratch_bigfloat2, XBIGFLOAT_DATA (number), scratch_bigfloat);
1228 1228
1286 int return_float) 1286 int return_float)
1287 { 1287 {
1288 1288
1289 if (return_float) 1289 if (return_float)
1290 { 1290 {
1291 if (INTP (number)) 1291 if (FIXNUMP (number))
1292 { 1292 {
1293 return values2 (make_float ((double) XINT (number)), Qzero); 1293 return values2 (make_float ((double) XFIXNUM (number)), Qzero);
1294 } 1294 }
1295 #ifdef HAVE_BIGNUM 1295 #ifdef HAVE_BIGNUM
1296 else if (BIGNUMP (number)) 1296 else if (BIGNUMP (number))
1297 { 1297 {
1298 return values2 (make_float 1298 return values2 (make_float
1316 1316
1317 static Lisp_Object 1317 static Lisp_Object
1318 floor_two_fixnum (Lisp_Object number, Lisp_Object divisor, 1318 floor_two_fixnum (Lisp_Object number, Lisp_Object divisor,
1319 int return_float) 1319 int return_float)
1320 { 1320 {
1321 EMACS_INT i1 = XREALINT (number); 1321 EMACS_INT i1 = XREALFIXNUM (number);
1322 EMACS_INT i2 = XREALINT (divisor); 1322 EMACS_INT i2 = XREALFIXNUM (divisor);
1323 EMACS_INT i3 = 0, i4 = 0; 1323 EMACS_INT i3 = 0, i4 = 0;
1324 Lisp_Object res0; 1324 Lisp_Object res0;
1325 1325
1326 if (i2 == 0) 1326 if (i2 == 0)
1327 return arith_error2 ("floor", number, divisor); 1327 return arith_error2 ("floor", number, divisor);
1340 { 1340 {
1341 res0 = make_float ((double)i3); 1341 res0 = make_float ((double)i3);
1342 } 1342 }
1343 else 1343 else
1344 { 1344 {
1345 res0 = make_int (i3); 1345 res0 = make_fixnum (i3);
1346 } 1346 }
1347 1347
1348 return values2 (res0, make_int (i4)); 1348 return values2 (res0, make_fixnum (i4));
1349 } 1349 }
1350 1350
1351 #ifdef HAVE_BIGNUM 1351 #ifdef HAVE_BIGNUM
1352 static Lisp_Object 1352 static Lisp_Object
1353 floor_two_bignum (Lisp_Object number, Lisp_Object divisor, 1353 floor_two_bignum (Lisp_Object number, Lisp_Object divisor,
1444 { 1444 {
1445 #ifdef HAVE_BIGNUM 1445 #ifdef HAVE_BIGNUM
1446 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat); 1446 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat);
1447 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1447 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1448 #else 1448 #else
1449 res0 = make_int ((EMACS_INT) bigfloat_to_long (scratch_bigfloat)); 1449 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (scratch_bigfloat));
1450 #endif /* HAVE_BIGNUM */ 1450 #endif /* HAVE_BIGNUM */
1451 } 1451 }
1452 1452
1453 bigfloat_mul (scratch_bigfloat2, scratch_bigfloat, 1453 bigfloat_mul (scratch_bigfloat2, scratch_bigfloat,
1454 XBIGFLOAT_DATA (divisor)); 1454 XBIGFLOAT_DATA (divisor));
1505 { 1505 {
1506 #ifdef HAVE_BIGNUM 1506 #ifdef HAVE_BIGNUM
1507 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat); 1507 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat);
1508 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1508 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1509 #else 1509 #else
1510 res0 = make_int ((EMACS_INT) bigfloat_to_long (scratch_bigfloat)); 1510 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (scratch_bigfloat));
1511 #endif /* HAVE_BIGNUM */ 1511 #endif /* HAVE_BIGNUM */
1512 } 1512 }
1513 1513
1514 bigfloat_sub (scratch_bigfloat2, XBIGFLOAT_DATA (number), scratch_bigfloat); 1514 bigfloat_sub (scratch_bigfloat2, XBIGFLOAT_DATA (number), scratch_bigfloat);
1515 return values2 (res0, make_bigfloat_bf (scratch_bigfloat2)); 1515 return values2 (res0, make_bigfloat_bf (scratch_bigfloat2));
1592 /* Algorithm taken from cl-extra.el, now to be found as cl-round in 1592 /* Algorithm taken from cl-extra.el, now to be found as cl-round in
1593 tests/automated/lisp-tests.el. */ 1593 tests/automated/lisp-tests.el. */
1594 static Lisp_Object 1594 static Lisp_Object
1595 round_two_fixnum (Lisp_Object number, Lisp_Object divisor, int return_float) 1595 round_two_fixnum (Lisp_Object number, Lisp_Object divisor, int return_float)
1596 { 1596 {
1597 EMACS_INT i1 = XREALINT (number); 1597 EMACS_INT i1 = XREALFIXNUM (number);
1598 EMACS_INT i2 = XREALINT (divisor); 1598 EMACS_INT i2 = XREALFIXNUM (divisor);
1599 EMACS_INT i0, hi2, flooring, floored, flsecond; 1599 EMACS_INT i0, hi2, flooring, floored, flsecond;
1600 1600
1601 if (i2 == 0) 1601 if (i2 == 0)
1602 return arith_error2 ("round", number, divisor); 1602 return arith_error2 ("round", number, divisor);
1603 1603
1615 && (i2 == (hi2 + hi2)) 1615 && (i2 == (hi2 + hi2))
1616 && (0 != (floored % 2))) 1616 && (0 != (floored % 2)))
1617 { 1617 {
1618 i0 = floored - 1; 1618 i0 = floored - 1;
1619 return values2 (return_float ? make_float ((double)i0) : 1619 return values2 (return_float ? make_float ((double)i0) :
1620 make_int (i0), make_int (hi2)); 1620 make_fixnum (i0), make_fixnum (hi2));
1621 } 1621 }
1622 else 1622 else
1623 { 1623 {
1624 return values2 (return_float ? make_float ((double)floored) : 1624 return values2 (return_float ? make_float ((double)floored) :
1625 make_int (floored), 1625 make_fixnum (floored),
1626 make_int (flsecond - hi2)); 1626 make_fixnum (flsecond - hi2));
1627 } 1627 }
1628 } 1628 }
1629 1629
1630 #ifdef HAVE_BIGNUM 1630 #ifdef HAVE_BIGNUM
1631 static void 1631 static void
1850 { 1850 {
1851 #ifdef HAVE_BIGNUM 1851 #ifdef HAVE_BIGNUM
1852 bignum_set_bigfloat (scratch_bignum, XBIGFLOAT_DATA (res0)); 1852 bignum_set_bigfloat (scratch_bignum, XBIGFLOAT_DATA (res0));
1853 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1853 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1854 #else 1854 #else
1855 res0 = make_int ((EMACS_INT) bigfloat_to_long (XBIGFLOAT_DATA (res0))); 1855 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (XBIGFLOAT_DATA (res0)));
1856 #endif /* HAVE_BIGNUM */ 1856 #endif /* HAVE_BIGNUM */
1857 } 1857 }
1858 1858
1859 return values2 (res0, res1); 1859 return values2 (res0, res1);
1860 } 1860 }
1902 { 1902 {
1903 #ifdef HAVE_BIGNUM 1903 #ifdef HAVE_BIGNUM
1904 bignum_set_bigfloat (scratch_bignum, XBIGFLOAT_DATA (res0)); 1904 bignum_set_bigfloat (scratch_bignum, XBIGFLOAT_DATA (res0));
1905 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1905 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1906 #else 1906 #else
1907 res0 = make_int ((EMACS_INT) bigfloat_to_long 1907 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long
1908 (XBIGFLOAT_DATA (res0))); 1908 (XBIGFLOAT_DATA (res0)));
1909 #endif /* HAVE_BIGNUM */ 1909 #endif /* HAVE_BIGNUM */
1910 } 1910 }
1911 1911
1912 return values2 (res0, res1); 1912 return values2 (res0, res1);
1992 1992
1993 static Lisp_Object 1993 static Lisp_Object
1994 truncate_two_fixnum (Lisp_Object number, Lisp_Object divisor, 1994 truncate_two_fixnum (Lisp_Object number, Lisp_Object divisor,
1995 int return_float) 1995 int return_float)
1996 { 1996 {
1997 EMACS_INT i1 = XREALINT (number); 1997 EMACS_INT i1 = XREALFIXNUM (number);
1998 EMACS_INT i2 = XREALINT (divisor); 1998 EMACS_INT i2 = XREALFIXNUM (divisor);
1999 EMACS_INT i0; 1999 EMACS_INT i0;
2000 2000
2001 if (i2 == 0) 2001 if (i2 == 0)
2002 return arith_error2 ("truncate", number, divisor); 2002 return arith_error2 ("truncate", number, divisor);
2003 2003
2008 ? (i1 <= 0 ? -i1 / -i2 : -(i1 / -i2)) 2008 ? (i1 <= 0 ? -i1 / -i2 : -(i1 / -i2))
2009 : (i1 < 0 ? -(-i1 / i2) : i1 / i2)); 2009 : (i1 < 0 ? -(-i1 / i2) : i1 / i2));
2010 2010
2011 if (return_float) 2011 if (return_float)
2012 { 2012 {
2013 return values2 (make_float ((double)i0), make_int (i1 - (i0 * i2))); 2013 return values2 (make_float ((double)i0), make_fixnum (i1 - (i0 * i2)));
2014 } 2014 }
2015 else 2015 else
2016 { 2016 {
2017 return values2 (make_int (i0), make_int (i1 - (i0 * i2))); 2017 return values2 (make_fixnum (i0), make_fixnum (i1 - (i0 * i2)));
2018 } 2018 }
2019 } 2019 }
2020 2020
2021 #ifdef HAVE_BIGNUM 2021 #ifdef HAVE_BIGNUM
2022 static Lisp_Object 2022 static Lisp_Object
2119 { 2119 {
2120 #ifdef HAVE_BIGNUM 2120 #ifdef HAVE_BIGNUM
2121 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat); 2121 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat);
2122 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 2122 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
2123 #else 2123 #else
2124 res0 = make_int ((EMACS_INT) bigfloat_to_long (scratch_bigfloat)); 2124 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (scratch_bigfloat));
2125 #endif /* HAVE_BIGNUM */ 2125 #endif /* HAVE_BIGNUM */
2126 } 2126 }
2127 2127
2128 bigfloat_mul (scratch_bigfloat2, scratch_bigfloat, XBIGFLOAT_DATA (divisor)); 2128 bigfloat_mul (scratch_bigfloat2, scratch_bigfloat, XBIGFLOAT_DATA (divisor));
2129 bigfloat_sub (scratch_bigfloat, XBIGFLOAT_DATA (number), scratch_bigfloat2); 2129 bigfloat_sub (scratch_bigfloat, XBIGFLOAT_DATA (number), scratch_bigfloat2);
2185 { 2185 {
2186 #ifdef HAVE_BIGNUM 2186 #ifdef HAVE_BIGNUM
2187 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat); 2187 bignum_set_bigfloat (scratch_bignum, scratch_bigfloat);
2188 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 2188 res0 = Fcanonicalize_number (make_bignum_bg (scratch_bignum));
2189 #else 2189 #else
2190 res0 = make_int ((EMACS_INT) bigfloat_to_long (scratch_bigfloat)); 2190 res0 = make_fixnum ((EMACS_INT) bigfloat_to_long (scratch_bigfloat));
2191 #endif /* HAVE_BIGNUM */ 2191 #endif /* HAVE_BIGNUM */
2192 } 2192 }
2193 2193
2194 bigfloat_sub (scratch_bigfloat2, XBIGFLOAT_DATA (number), scratch_bigfloat); 2194 bigfloat_sub (scratch_bigfloat2, XBIGFLOAT_DATA (number), scratch_bigfloat);
2195 2195
2230 Lisp_Object res0 2230 Lisp_Object res0
2231 = float_to_int (XFLOAT_DATA (number), MAYBE_EFF ("truncate"), 2231 = float_to_int (XFLOAT_DATA (number), MAYBE_EFF ("truncate"),
2232 number, Qunbound); 2232 number, Qunbound);
2233 if (return_float) 2233 if (return_float)
2234 { 2234 {
2235 res0 = make_float ((double)XINT(res0)); 2235 res0 = make_float ((double)XFIXNUM(res0));
2236 return values2 (res0, make_float ((XFLOAT_DATA (number) 2236 return values2 (res0, make_float ((XFLOAT_DATA (number)
2237 - XFLOAT_DATA (res0)))); 2237 - XFLOAT_DATA (res0))));
2238 } 2238 }
2239 else 2239 else
2240 { 2240 {
2241 return values2 (res0, make_float (XFLOAT_DATA (number) 2241 return values2 (res0, make_float (XFLOAT_DATA (number)
2242 - XREALINT (res0))); 2242 - XREALFIXNUM (res0)));
2243 } 2243 }
2244 } 2244 }
2245 2245
2246 EXFUN (Fftruncate, 2); 2246 EXFUN (Fftruncate, 2);
2247 2247