1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

(scm_angle): Use scm_flo0 for non-negative inum, bignum and real.

This commit is contained in:
Kevin Ryde 2003-07-24 01:03:40 +00:00
parent cfc9fc1c82
commit c8ae173e8a

View file

@ -4257,10 +4257,14 @@ SCM_GPROC (s_angle, "angle", 1, 0, 0, scm_angle, g_angle);
SCM
scm_angle (SCM z)
{
/* atan(0,-1) is pi and it'd be possible to have that as a constant like
scm_flo0 to save allocating a new flonum with scm_make_real each time.
But if atan2 follows the floating point rounding mode, then the value
is not a constant. Maybe it'd be close enough though. */
if (SCM_INUMP (z))
{
if (SCM_INUM (z) >= 0)
return scm_make_real (atan2 (0.0, 1.0));
return scm_flo0;
else
return scm_make_real (atan2 (0.0, -1.0));
}
@ -4271,10 +4275,15 @@ scm_angle (SCM z)
if (sgn < 0)
return scm_make_real (atan2 (0.0, -1.0));
else
return scm_make_real (atan2 (0.0, 1.0));
return scm_flo0;
}
else if (SCM_REALP (z))
return scm_make_real (atan2 (0.0, SCM_REAL_VALUE (z)));
{
if (SCM_REAL_VALUE (z) >= 0)
return scm_flo0;
else
return scm_make_real (atan2 (0.0, -1.0));
}
else if (SCM_COMPLEXP (z))
return scm_make_real (atan2 (SCM_COMPLEX_IMAG (z), SCM_COMPLEX_REAL (z)));
else