[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 82/85: Simplify scm_abs for the real case
From: |
Andy Wingo |
Subject: |
[Guile-commits] 82/85: Simplify scm_abs for the real case |
Date: |
Thu, 13 Jan 2022 03:40:27 -0500 (EST) |
wingo pushed a commit to branch main
in repository guile.
commit 6058d9e05ddd1350228c2d83485a5bd7484a509c
Author: Daniel Llorens <lloda@sarc.name>
AuthorDate: Mon Jan 10 12:21:26 2022 +0100
Simplify scm_abs for the real case
* libguile/numbers.c (scm_abs): As stated. When x is a nan with the sign bit
set, this changes the behavior of (magnitude x) back to what it was in
3.0.7,
to clear that bit.
---
libguile/numbers.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 9ff870aa7..1a96d9c8c 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -658,17 +658,7 @@ SCM_PRIMITIVE_GENERIC (scm_abs, "abs", 1, 0, 0,
if (SCM_I_INUMP (x))
return scm_integer_abs_i (SCM_I_INUM (x));
else if (SCM_LIKELY (SCM_REALP (x)))
- {
- double xx = SCM_REAL_VALUE (x);
- /* If x is a NaN then xx<0 is false so we return x unchanged */
- if (xx < 0.0)
- return scm_i_from_double (-xx);
- /* Handle signed zeroes properly */
- else if (SCM_UNLIKELY (xx == 0.0))
- return flo0;
- else
- return x;
- }
+ return scm_i_from_double (copysign (SCM_REAL_VALUE (x), 1.0));
else if (SCM_BIGP (x))
return scm_integer_abs_z (scm_bignum (x));
else if (SCM_FRACTIONP (x))
- [Guile-commits] 52/85: Implement scm_{to,from}_wchar inline, (continued)
- [Guile-commits] 52/85: Implement scm_{to,from}_wchar inline, Andy Wingo, 2022/01/13
- [Guile-commits] 58/85: Remove dead bignum frexp code from numbers.c, Andy Wingo, 2022/01/13
- [Guile-commits] 53/85: Remove unused conv-{u,}integer.i.c, Andy Wingo, 2022/01/13
- [Guile-commits] 63/85: Use scm_integer_to_double_z in numbers.c instead of big2dbl, Andy Wingo, 2022/01/13
- [Guile-commits] 66/85: Finish srfi-60 port off old scm mpz API, Andy Wingo, 2022/01/13
- [Guile-commits] 74/85: Less pessimal scm_integer_sub_zi, Andy Wingo, 2022/01/13
- [Guile-commits] 76/85: Avoid bignum clone in scm_integer_sub_zz, Andy Wingo, 2022/01/13
- [Guile-commits] 79/85: Optimize scm_integer_mul_ii, Andy Wingo, 2022/01/13
- [Guile-commits] 80/85: Optimize integer-expt for fixnums, Andy Wingo, 2022/01/13
- [Guile-commits] 81/85: Optimize logand against a positive inum, Andy Wingo, 2022/01/13
- [Guile-commits] 82/85: Simplify scm_abs for the real case,
Andy Wingo <=
- [Guile-commits] 09/85: Implement ceiling-divide with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 08/85: Implement ceiling-remainder with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 11/85: Implement truncate-remainder with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 49/85: Reimplement scm_from_int8 etc, Andy Wingo, 2022/01/13
- [Guile-commits] 55/85: Reimplement exact-integer-sqrt with integers.[ch], Andy Wingo, 2022/01/13
- [Guile-commits] 56/85: Refactor scm_sqrt in terms of integers.[ch], Andy Wingo, 2022/01/13
- [Guile-commits] 62/85: Simplify magnitude, angle, Andy Wingo, 2022/01/13
- [Guile-commits] 65/85: Start porting srfi-60 off the bad bignum interfaces, Andy Wingo, 2022/01/13
- [Guile-commits] 72/85: Optimize scm_integer_mul_zi, Andy Wingo, 2022/01/13
- [Guile-commits] 75/85: Start to optimize scm_integer_sub_iz, Andy Wingo, 2022/01/13