Grammar fix.
[bpt/guile.git] / libguile / numbers.h
index 16f72b4..f09c1cb 100644 (file)
  * If you write modifications of your own for GUILE, it is your choice
  * whether to permit this exception to apply to your modifications.
  * If you do not wish that, delete this exception notice.  */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+   gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
 \f
 
 #include "libguile/__scm.h"
 
+#include "libguile/print.h"
+
 \f
 
 
 /* Numbers 
  */
 
-#define SCM_INEXP(x) (SCM_TYP16(x)==scm_tc16_flo)
-#define SCM_CPLXP(x) (SCM_CAR(x)==scm_tc_dblc)
+#define SCM_INEXP(x) (SCM_NIMP(x) && (SCM_TYP16(x)==scm_tc16_flo))
+#define SCM_CPLXP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_dblc))
 #define SCM_REAL(x) (*(((scm_dbl *) (SCM2PTR(x)))->real))
 #define SCM_IMAG(x) (*((double *)(SCM_CHARS(x)+sizeof(double))))
 /* ((&SCM_REAL(x))[1]) */
 
 
 #ifdef SCM_SINGLES
-#define SCM_REALP(x) ((~SCM_REAL_PART & SCM_CAR(x))==scm_tc_flo)
-#define SCM_SINGP(x) (SCM_CAR(x)==scm_tc_flo)
+#define SCM_REALP(x) (SCM_NIMP(x) && ((~SCM_REAL_PART & SCM_CAR(x))==scm_tc_flo))
+#define SCM_SINGP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_flo))
 #define SCM_FLO(x) (((scm_flo *)(SCM2PTR(x)))->num)
 #define SCM_REALPART(x) (SCM_SINGP(x)?0.0+SCM_FLO(x):SCM_REAL(x))
 #else /* SCM_SINGLES */
-#define SCM_REALP(x) (SCM_CAR(x)==scm_tc_dblr)
+#define SCM_REALP(x) (SCM_NIMP(x) && (SCM_CAR(x)==scm_tc_dblr))
 #define SCM_REALPART SCM_REAL
 #endif /* SCM_SINGLES */
 
 
 # define SCM_BIGRAD (1L << SCM_BITSPERDIG)
 # define SCM_DIGSPERLONG ((scm_sizet)((sizeof(long)*SCM_CHAR_BIT+SCM_BITSPERDIG-1)/SCM_BITSPERDIG))
-# define SCM_DIGSPERLONGLONG ((scm_sizet)((sizeof(long long)*SCM_CHAR_BIT+SCM_BITSPERDIG-1)/SCM_BITSPERDIG))
 # define SCM_BIGUP(x) ((unsigned long)(x) << SCM_BITSPERDIG)
 # define SCM_LONGLONGBIGUP(x) ((ulong_long)(x) << SCM_BITSPERDIG)
 # define SCM_BIGDN(x) ((x) >> SCM_BITSPERDIG)
 # define SCM_BIGLO(x) ((x) & (SCM_BIGRAD-1))
+
 #endif /* def BIGNUMS */
 
 #ifndef SCM_BIGDIG
 #define SCM_NUM2DBL(x) ((double) SCM_INUM (x))
 #endif
 #endif
-#define SCM_NUMP(x) ((0xfcff & (int)SCM_CAR(x))==scm_tc7_smob)
-#define SCM_BIGP(x) (SCM_TYP16S(x)==scm_tc16_bigpos)
+#define SCM_NUMP(x) (SCM_NIMP(x) && (0xfcff & (int)SCM_CAR(x))==scm_tc7_smob)
+#define SCM_BIGP(x) (SCM_NIMP(x) && SCM_TYP16S(x)==scm_tc16_bigpos)
 #define SCM_BIGSIGN(x) (0x0100 & (int)SCM_CAR(x))
 #define SCM_BDIGITS(x) ((SCM_BIGDIG *)(SCM_CDR(x)))
 #define SCM_NUMDIGS(x) ((scm_sizet)(SCM_CAR(x)>>16))
@@ -306,7 +311,7 @@ extern SCM scm_min SCM_P ((SCM x, SCM y));
 extern SCM scm_sum SCM_P ((SCM x, SCM y));
 extern SCM scm_difference SCM_P ((SCM x, SCM y));
 extern SCM scm_product SCM_P ((SCM x, SCM y));
-extern double scm_num2dbl SCM_P ((SCM a, char * why));
+extern double scm_num2dbl SCM_P ((SCM a, const char * why));
 extern SCM scm_divide SCM_P ((SCM x, SCM y));
 extern double scm_asinh SCM_P ((double x));
 extern double scm_acosh SCM_P ((double x));
@@ -329,9 +334,11 @@ extern double scm_big2dbl SCM_P ((SCM b));
 extern SCM scm_long2num SCM_P ((long sl));
 extern SCM scm_long_long2num SCM_P ((long_long sl));
 extern SCM scm_ulong2num SCM_P ((unsigned long sl));
-extern long scm_num2long SCM_P ((SCM num, char *pos, char *s_caller));
-extern long_long scm_num2long_long SCM_P ((SCM num, char *pos, char *s_caller));
-extern unsigned long scm_num2ulong SCM_P ((SCM num, char *pos, char *s_caller));
+extern long scm_num2long SCM_P ((SCM num, char *pos, const char *s_caller));
+extern long_long scm_num2long_long SCM_P ((SCM num, char *pos,
+                                          const char *s_caller));
+extern unsigned long scm_num2ulong SCM_P ((SCM num, char *pos,
+                                          const char *s_caller));
 extern void scm_init_numbers SCM_P ((void));
 
 #endif  /* NUMBERSH */