summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/ChangeLog5
-rw-r--r--libguile/numbers.h15
2 files changed, 20 insertions, 0 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 48d5433a5..00cc991fb 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,8 @@
+1998-07-02 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
+
+ * numbers.h (SCM_NUM2DBL): New macro. Complements SCM_NUMBERP.
+ This macro is useful in applications.
+
1998-06-21 Mikael Djurfeldt <mdj@barbara.nada.kth.se>
* load.c (scm_internal_parse_path): Renamed from scm_parse_path.
diff --git a/libguile/numbers.h b/libguile/numbers.h
index 26aee98c7..aac0b10fe 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -185,11 +185,26 @@
#ifdef SCM_FLOATS
#define SCM_NUMBERP(x) (SCM_INUMP(x) || (SCM_NIMP(x) && SCM_NUMP(x)))
+#ifdef SCM_BIGDIG
+#define SCM_NUM2DBL(x) (SCM_INUMP (x) \
+ ? (double) SCM_INUM (x) \
+ : (SCM_REALP (x) \
+ ? SCM_REALPART (x) \
+ : scm_big2dbl (x)))
+#else
+#define SCM_NUM2DBL(x) (SCM_INUMP (x) \
+ ? (double) SCM_INUM (x) \
+ : SCM_REALPART (x))
+#endif
#else
#ifdef SCM_BIGDIG
#define SCM_NUMBERP(x) (SCM_INUMP(x) || (SCM_NIMP(x) && SCM_NUMP(x)))
+#define SCM_NUM2DBL(x) (SCM_INUMP (x) \
+ ? (double) SCM_INUM (x) \
+ : scm_big2dbl (x))
#else
#define SCM_NUMBERP SCM_INUMP
+#define SCM_NUM2DBL(x) ((double) SCM_INUM (x))
#endif
#endif
#define SCM_NUMP(x) ((0xfcff & (int)SCM_CAR(x))==scm_tc7_smob)