POSITIVE-FIXNUM? and NEGATIVE-FIXNUM? and appropriate guarantees.
authorJoe Marshall <jmarshall@alum.mit.edu>
Tue, 30 Mar 2010 22:25:46 +0000 (15:25 -0700)
committerJoe Marshall <jmarshall@alum.mit.edu>
Tue, 30 Mar 2010 22:25:46 +0000 (15:25 -0700)
src/runtime/fixart.scm

index 3e888c325f379f49ffff7470e4ba1d31a630a802..eb0d8ce843b74d5a5ddde37fa92eeec9943d03bf 100644 (file)
@@ -108,6 +108,29 @@ USA.
   (flo:vector-ref floating-vector-ref 2)
   (flo:vector-set! floating-vector-set! 3))
 \f
+(define-guarantee fixnum "fixnum")
+
+(define-integrable (positive-fixnum? object)
+  (and (fixnum? object)
+       (fix:positive? object)))
+
+(define-integrable (negative-fixnum? object)
+  (and (fixnum? object)
+       (fix:negative? object)))
+
+(define-integrable (non-negative-fixnum? object)
+  (and (fixnum? object)
+       (not (fix:negative? object))))
+
+(define-integrable (non-positive-fixnum? object)
+  (and (fixnum? object)
+       (not (fix:positive? object))))
+
+(define-guarantee positive-fixnum "positive fixnum")
+(define-guarantee negative-fixnum "negative fixnum")
+(define-guarantee non-positive-fixnum "non-positive fixnum")
+(define-guarantee non-negative-fixnum "non-negative fixnum")
+\f
 (define-integrable (guarantee-index-fixnum object caller)
   (if (not (index-fixnum? object))
       (error:wrong-type-argument object "index integer" caller)))