Mercurial > emacs
changeset 84998:259a9fdd1450
(Fexpt): Manually check for overflows, so that a power
of a non-zero value can't yield zero.
author | Michaël Cadilhac <michael.cadilhac@lrde.org> |
---|---|
date | Mon, 01 Oct 2007 09:17:14 +0000 |
parents | 0157774b2cf9 |
children | b80e8b2a64e4 |
files | src/floatfns.c |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/floatfns.c Mon Oct 01 06:36:58 2007 +0000 +++ b/src/floatfns.c Mon Oct 01 09:17:14 2007 +0000 @@ -454,7 +454,7 @@ (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 @@ 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,