From: Michaƫl Cadilhac Date: Mon, 1 Oct 2007 09:17:29 +0000 (+0000) Subject: (Fexpt): Manually check for overflows, so that a power X-Git-Tag: emacs-pretest-23.0.90~10559 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2742fe306859d828cbeff3ae0371e2217b09cd4c;p=emacs.git (Fexpt): Manually check for overflows, so that a power of a non-zero value can't yield zero. --- diff --git a/src/ChangeLog b/src/ChangeLog index 70fbaad280e..e71218880bc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-10-01 Micha,Ak(Bl Cadilhac + + * floatfns.c (Fexpt): Manually check for overflows, so that a power + of a non-zero value can't yield zero. + 2007-09-29 Stefan Monnier * term.c (term_clear_mouse_face, term_mouse_highlight) diff --git a/src/floatfns.c b/src/floatfns.c index 6ad9b95686e..a20f7981bf0 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -454,7 +454,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, (arg1, arg2) register Lisp_Object arg1, arg2; { - double f1, f2; + double f1, f2, f3; CHECK_NUMBER_OR_FLOAT (arg1); CHECK_NUMBER_OR_FLOAT (arg2); @@ -500,8 +500,11 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor(f2))) domain_error2 ("expt", arg1, arg2); #endif - IN_FLOAT2 (f1 = pow (f1, f2), "expt", arg1, arg2); - return make_float (f1); + IN_FLOAT2 (f3 = pow (f1, f2), "expt", arg1, arg2); + /* Check for overflow in the result. */ + if (f1 != 0.0 && f3 == 0.0) + range_error ("expt", arg1); + return make_float (f3); } DEFUN ("log", Flog, Slog, 1, 2, 0,