commit 85fdeb423f983ee1d3eaba63227710c38c29eed5
parent 9692c5fd0c1334106ed608fa85bc80bd398e0803
Author: Ed van Bruggen <edvb@uw.edu>
Date: Fri, 7 Jun 2019 11:00:53 -0700
sgn return 0 if given 0
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tibs/lib.tsp b/tibs/lib.tsp
@@ -119,7 +119,7 @@
(define (log10 x) (logb 10. x))
(define (abs x) (if (>= x 0) x (- x)))
-(define (sgn x) (if (>= x 0) 1 -1))
+(define (sgn x) (cond ((= x 0) 0) ((> x 0) 1) (else -1)))
(define (max a b) (if (> a b) a b))
(define (min a b) (if (< a b) a b))