+2000-05-10 Dirk Herrmann <D.Herrmann@tu-bs.de>
+
+ * numbers.c (IS_INF, isfinite): Added FIXME comment.
+
+ (scm_abs, scm_magnitude): Make these two independent of each
+ other. scm_abs now reports an error if given a complex argument.
+
+ (scm_istr2flo, scm_integer_p). Use SCM_REAL_VALUE instead of
+ SCM_REALPART if the object is known to be real.
+
+ (scm_init_numbers): No need to use SCM_NEWREAL macro for speed
+ here.
+
+ * numbers.h (SCM_SINGP): Set to 0 instead of SCM_BOOL_F.
+
2000-05-10 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eq.c (scm_eqv_p): Separate handling of real and complex
/* IS_INF tests its floating point number for infiniteness
+ Dirk:FIXME:: This test does not work if x == 0
*/
#ifndef IS_INF
#define IS_INF(x) ((x) == (x) / 2)
#endif
+
/* Return true if X is not infinite and is not a NaN
+ Dirk:FIXME:: Since IS_INF is broken, this test does not work if x == 0
*/
#ifndef isfinite
#define isfinite(x) (!IS_INF (x) && (x) == (x))
} else {
return scm_copybig (x, 0);
}
+ } else if (SCM_REALP (x)) {
+ return scm_make_real (fabs (SCM_REAL_VALUE (x)));
} else {
SCM_WTA_DISPATCH_1 (g_abs, x, 1, s_abs);
}
return SCM_BOOL_F; /* not `real' */
if (SCM_SLOPPY_COMPLEXP (second))
return SCM_BOOL_F; /* not `real' */
- tmp = SCM_REALPART (second);
+ tmp = SCM_REAL_VALUE (second);
return scm_make_complex (res * cos (tmp), res * sin (tmp));
}
default:
return SCM_BOOL_F; /* not `ureal' */
if (SCM_SLOPPY_COMPLEXP (second))
return SCM_BOOL_F; /* not `ureal' */
- tmp = SCM_REALPART (second);
+ tmp = SCM_REAL_VALUE (second);
if (tmp < 0.0)
return SCM_BOOL_F; /* not `ureal' */
return scm_make_complex (res, (lead_sgn * tmp));
#undef FUNC_NAME
/*** END strs->nums ***/
+
SCM
scm_make_real (double x)
{
return z;
}
+
SCM
scm_make_complex (double x, double y)
{
return z;
}
+
SCM
scm_bigequal (SCM x, SCM y)
{
return SCM_BOOL_F;
if (SCM_SLOPPY_COMPLEXP (x))
return SCM_BOOL_F;
- r = SCM_REALPART (x);
+ r = SCM_REAL_VALUE (x);
if (r == floor (r))
return SCM_BOOL_T;
return SCM_BOOL_F;
scm_magnitude (SCM z)
{
if (SCM_INUMP (z)) {
- return scm_abs (z);
+ long int zz = SCM_INUM (z);
+ if (zz >= 0) {
+ return z;
+ } else if (SCM_POSFIXABLE (-zz)) {
+ return SCM_MAKINUM (-zz);
+ } else {
+#ifdef SCM_BIGDIG
+ return scm_long2big (-zz);
+#else
+ scm_num_overflow (s_magnitude);
+#endif
+ }
} else if (SCM_BIGP (z)) {
- return scm_abs (z);
+ if (!SCM_BIGSIGN (z)) {
+ return z;
+ } else {
+ return scm_copybig (z, 0);
+ }
} else if (SCM_REALP (z)) {
return scm_make_real (fabs (SCM_REAL_VALUE (z)));
} else if (SCM_COMPLEXP (z)) {
{
scm_add_feature ("complex");
scm_add_feature ("inexact");
- SCM_NEWREAL (scm_flo0, 0.0);
+ scm_flo0 = scm_make_real (0.0);
#ifdef DBL_DIG
scm_dblprec = (DBL_DIG > 20) ? 20 : DBL_DIG;
#else