mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
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.
This commit is contained in:
parent
9e5aa173c7
commit
6058d9e05d
1 changed files with 1 additions and 11 deletions
|
@ -658,17 +658,7 @@ SCM_PRIMITIVE_GENERIC (scm_abs, "abs", 1, 0, 0,
|
||||||
if (SCM_I_INUMP (x))
|
if (SCM_I_INUMP (x))
|
||||||
return scm_integer_abs_i (SCM_I_INUM (x));
|
return scm_integer_abs_i (SCM_I_INUM (x));
|
||||||
else if (SCM_LIKELY (SCM_REALP (x)))
|
else if (SCM_LIKELY (SCM_REALP (x)))
|
||||||
{
|
return scm_i_from_double (copysign (SCM_REAL_VALUE (x), 1.0));
|
||||||
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;
|
|
||||||
}
|
|
||||||
else if (SCM_BIGP (x))
|
else if (SCM_BIGP (x))
|
||||||
return scm_integer_abs_z (scm_bignum (x));
|
return scm_integer_abs_z (scm_bignum (x));
|
||||||
else if (SCM_FRACTIONP (x))
|
else if (SCM_FRACTIONP (x))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue