From d9098370d8412aa602be9da856a5080818d6f60a Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Wed, 9 Mar 2011 10:27:42 -0800 Subject: [PATCH] Add GUARANTEEs for positive, negative, non-positive, and non-negative numbers. --- src/runtime/arith.scm | 11 +++++++++++ src/runtime/runtime.pkg | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/runtime/arith.scm b/src/runtime/arith.scm index 37d105033..da78fef88 100644 --- a/src/runtime/arith.scm +++ b/src/runtime/arith.scm @@ -1846,6 +1846,17 @@ USA. (define-guarantee exact-nonnegative-integer "exact non-negative integer") (define-guarantee exact-positive-integer "exact positive integer") +(define (non-negative? object) + (not (negative? object))) + +(define (non-positive? object) + (not (positive? object))) + +(define-guarantee positive "positive number") +(define-guarantee negative "negative number") +(define-guarantee non-positive "non-positive number") +(define-guarantee non-negative "non-negative number") + ;;; The following three procedures were originally just renamings of ;;; their COMPLEX: equivalents. They have been rewritten this way to ;;; cause the compiler to generate better code for them. diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 3537ad6fd..9b5525cfb 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -2874,7 +2874,11 @@ USA. error:not-exact-rational error:not-inexact error:not-integer + error:not-negative + error:not-non-negative + error:not-non-positive error:not-number + error:not-positive error:not-rational error:not-real exact-nonnegative-integer? @@ -2895,7 +2899,11 @@ USA. guarantee-exact-rational guarantee-inexact guarantee-integer + guarantee-negative + guarantee-non-negative + guarantee-non-positive guarantee-number + guarantee-positive guarantee-rational guarantee-real inexact? @@ -2906,6 +2914,8 @@ USA. max min modulo + non-negative? + non-positive? number->string odd? quotient -- 2.25.1