comparison src/floatfns.c @ 90533:8a8e69664178

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 343-356) - Update from CVS - Update for ERC 5.1.3. - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 113-115) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-90
author Miles Bader <miles@gnu.org>
date Wed, 19 Jul 2006 00:42:56 +0000
parents c5406394f567 6b2f430f5341
children 95d0cdf160ea
comparison
equal deleted inserted replaced
90532:e22cf6d2400c 90533:8a8e69664178
199 XSETINT (i, (EMACS_INT)(x)); \ 199 XSETINT (i, (EMACS_INT)(x)); \
200 } \ 200 } \
201 while (0) 201 while (0)
202 202
203 #define arith_error(op,arg) \ 203 #define arith_error(op,arg) \
204 Fsignal (Qarith_error, Fcons (build_string ((op)), Fcons ((arg), Qnil))) 204 xsignal2 (Qarith_error, build_string ((op)), (arg))
205 #define range_error(op,arg) \ 205 #define range_error(op,arg) \
206 Fsignal (Qrange_error, Fcons (build_string ((op)), Fcons ((arg), Qnil))) 206 xsignal2 (Qrange_error, build_string ((op)), (arg))
207 #define range_error2(op,a1,a2) \ 207 #define range_error2(op,a1,a2) \
208 Fsignal (Qrange_error, Fcons (build_string ((op)), \ 208 xsignal3 (Qrange_error, build_string ((op)), (a1), (a2))
209 Fcons ((a1), Fcons ((a2), Qnil))))
210 #define domain_error(op,arg) \ 209 #define domain_error(op,arg) \
211 Fsignal (Qdomain_error, Fcons (build_string ((op)), Fcons ((arg), Qnil))) 210 xsignal2 (Qdomain_error, build_string ((op)), (arg))
212 #define domain_error2(op,a1,a2) \ 211 #define domain_error2(op,a1,a2) \
213 Fsignal (Qdomain_error, Fcons (build_string ((op)), \ 212 xsignal3 (Qdomain_error, build_string ((op)), (a1), (a2))
214 Fcons ((a1), Fcons ((a2), Qnil))))
215 213
216 /* Extract a Lisp number as a `double', or signal an error. */ 214 /* Extract a Lisp number as a `double', or signal an error. */
217 215
218 double 216 double
219 extract_float (num) 217 extract_float (num)
754 double f1, f2; 752 double f1, f2;
755 753
756 f1 = FLOATP (arg) ? XFLOAT_DATA (arg) : XINT (arg); 754 f1 = FLOATP (arg) ? XFLOAT_DATA (arg) : XINT (arg);
757 f2 = (FLOATP (divisor) ? XFLOAT_DATA (divisor) : XINT (divisor)); 755 f2 = (FLOATP (divisor) ? XFLOAT_DATA (divisor) : XINT (divisor));
758 if (! IEEE_FLOATING_POINT && f2 == 0) 756 if (! IEEE_FLOATING_POINT && f2 == 0)
759 Fsignal (Qarith_error, Qnil); 757 xsignal0 (Qarith_error);
760 758
761 IN_FLOAT2 (f1 = (*double_round) (f1 / f2), name, arg, divisor); 759 IN_FLOAT2 (f1 = (*double_round) (f1 / f2), name, arg, divisor);
762 FLOAT_TO_INT2 (f1, arg, name, arg, divisor); 760 FLOAT_TO_INT2 (f1, arg, name, arg, divisor);
763 return arg; 761 return arg;
764 } 762 }
765 763
766 i1 = XINT (arg); 764 i1 = XINT (arg);
767 i2 = XINT (divisor); 765 i2 = XINT (divisor);
768 766
769 if (i2 == 0) 767 if (i2 == 0)
770 Fsignal (Qarith_error, Qnil); 768 xsignal0 (Qarith_error);
771 769
772 XSETINT (arg, (*int_round2) (i1, i2)); 770 XSETINT (arg, (*int_round2) (i1, i2));
773 return arg; 771 return arg;
774 } 772 }
775 773
905 903
906 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x); 904 f1 = FLOATP (x) ? XFLOAT_DATA (x) : XINT (x);
907 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y); 905 f2 = FLOATP (y) ? XFLOAT_DATA (y) : XINT (y);
908 906
909 if (! IEEE_FLOATING_POINT && f2 == 0) 907 if (! IEEE_FLOATING_POINT && f2 == 0)
910 Fsignal (Qarith_error, Qnil); 908 xsignal0 (Qarith_error);
911 909
912 /* If the "remainder" comes out with the wrong sign, fix it. */ 910 /* If the "remainder" comes out with the wrong sign, fix it. */
913 IN_FLOAT2 ((f1 = fmod (f1, f2), 911 IN_FLOAT2 ((f1 = fmod (f1, f2),
914 f1 = (f2 < 0 ? f1 > 0 : f1 < 0) ? f1 + f2 : f1), 912 f1 = (f2 < 0 ? f1 > 0 : f1 < 0) ? f1 + f2 : f1),
915 "mod", x, y); 913 "mod", x, y);
984 #endif /* BSD_SYSTEM */ 982 #endif /* BSD_SYSTEM */
985 983
986 SIGNAL_THREAD_CHECK (signo); 984 SIGNAL_THREAD_CHECK (signo);
987 in_float = 0; 985 in_float = 0;
988 986
989 Fsignal (Qarith_error, Fcons (float_error_arg, Qnil)); 987 xsignal1 (Qarith_error, float_error_arg);
990 } 988 }
991 989
992 /* Another idea was to replace the library function `infnan' 990 /* Another idea was to replace the library function `infnan'
993 where SIGILL is signaled. */ 991 where SIGILL is signaled. */
994 992
1012 ((!strcmp (x->name, "log") || !strcmp (x->name, "pow")) 1010 ((!strcmp (x->name, "log") || !strcmp (x->name, "pow"))
1013 ? Fcons (make_float (x->arg2), Qnil) 1011 ? Fcons (make_float (x->arg2), Qnil)
1014 : Qnil))); 1012 : Qnil)));
1015 switch (x->type) 1013 switch (x->type)
1016 { 1014 {
1017 case DOMAIN: Fsignal (Qdomain_error, args); break; 1015 case DOMAIN: xsignal (Qdomain_error, args); break;
1018 case SING: Fsignal (Qsingularity_error, args); break; 1016 case SING: xsignal (Qsingularity_error, args); break;
1019 case OVERFLOW: Fsignal (Qoverflow_error, args); break; 1017 case OVERFLOW: xsignal (Qoverflow_error, args); break;
1020 case UNDERFLOW: Fsignal (Qunderflow_error, args); break; 1018 case UNDERFLOW: xsignal (Qunderflow_error, args); break;
1021 default: Fsignal (Qarith_error, args); break; 1019 default: xsignal (Qarith_error, args); break;
1022 } 1020 }
1023 return (1); /* don't set errno or print a message */ 1021 return (1); /* don't set errno or print a message */
1024 } 1022 }
1025 #endif /* HAVE_MATHERR */ 1023 #endif /* HAVE_MATHERR */
1026 1024