diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-11-20 21:33:40 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-11-20 21:33:40 -0800 |
commit | c3bd722120585c59c47dff6a98948cd89cc8b28e (patch) | |
tree | a3679fd0570cf37154ed47582204f0ee4fd83b74 | |
parent | 224a72b55144f4c098295d947c4bd26da56c2c68 (diff) | |
download | txr-c3bd722120585c59c47dff6a98948cd89cc8b28e.tar.gz txr-c3bd722120585c59c47dff6a98948cd89cc8b28e.tar.bz2 txr-c3bd722120585c59c47dff6a98948cd89cc8b28e.zip |
expt: zero exponent yields 1.0.
* arith.c (expt): NUM-FLNUM, FLNUM-NUM and FLNUM-FLNUM cases
ensure that if the expontent is zero, the return value is
1.0. Implementations of pow do this, but ISO C doesn't require it.
* txr.1: Now documented.
-rw-r--r-- | arith.c | 6 | ||||
-rw-r--r-- | txr.1 | 3 |
2 files changed, 9 insertions, 0 deletions
@@ -2468,6 +2468,8 @@ tail: cnum a = c_n(anum); double b = c_flo(bnum, self); + if (b == 0.0) + return flo(1.0); if (a == 0 && b < 0) goto divzero; return flo(pow(a, b)); @@ -2477,6 +2479,8 @@ tail: double a = c_flo(anum, self); cnum b = c_n(bnum); + if (b == 0) + return flo(1.0); if (a == 0 && b < 0) goto divzero; return flo(pow(a, b)); @@ -2486,6 +2490,8 @@ tail: { double a = c_flo(anum, self); double b = c_flo(bnum, self); + if (b == 0.0) + return flo(1.0); if (a == 0 && b < 0) goto divzero; return flo(pow(a, b)); @@ -48549,6 +48549,9 @@ operand is converted to a float, and a floating point exponentiation is performed. Exponentiation that would produce a complex number is not supported. +If the exponent is zero, then the return value is 1.0 if at least one operand +is floating-point, otherwise 1. + The .code sqrt function produces a floating-point square root of |