]> gitweb.factorcode.org Git - factor.git/commitdiff
math: neg? needs to be defined for all reals
authorJoe Groff <arcata@gmail.com>
Sat, 26 Nov 2011 23:37:58 +0000 (15:37 -0800)
committerJoe Groff <arcata@gmail.com>
Sat, 26 Nov 2011 23:37:58 +0000 (15:37 -0800)
core/math/integers/integers.factor
core/math/math-tests.factor
core/math/math.factor

index 0457165fac9ab067240fb58140368523d940e900..3cab1dd4e83c06adb12d466555e3eb4def6c1bdd 100644 (file)
@@ -8,8 +8,6 @@ IN: math.integers.private
 : fixnum-min ( x y -- z ) [ fixnum< ] most ; foldable
 : fixnum-max ( x y -- z ) [ fixnum> ] most ; foldable
 
-M: integer neg? 0 < ; inline
-
 M: integer numerator ; inline
 M: integer denominator drop 1 ; inline
 
index 8ed5495106e7cc0681662fd2c0dc63276bd63170..8cbc951a36e36d38d95fbeada1690ca4ba8e4447 100644 (file)
@@ -67,4 +67,15 @@ IN: math.tests
 [ f ] [ -1/0. 0/0. >= ] unit-test
 [ f ] [  1/0. 0/0. >= ] unit-test
 
-
+[ f ] [ 0 neg? ] unit-test
+[ f ] [ 1/2 neg? ] unit-test
+[ f ] [ 1 neg? ] unit-test
+[ t ] [ -1/2 neg? ] unit-test
+[ t ] [ -1 neg? ] unit-test
+
+[ f ] [ 0.0 neg? ] unit-test
+[ f ] [ 1.0 neg? ] unit-test
+[ f ] [ 1/0. neg? ] unit-test
+[ t ] [ -0.0 neg? ] unit-test
+[ t ] [ -1.0 neg? ] unit-test
+[ t ] [ -1/0. neg? ] unit-test
index 94a0db98c3fc28b56c1ad1ad4072ac061b41cc54..150f508cdbf20c138f4c87d8968d409d3b8127e5 100644 (file)
@@ -88,6 +88,8 @@ TUPLE: ratio { numerator integer read-only } { denominator integer read-only } ;
 
 UNION: rational integer ratio ;
 
+M: rational neg? 0 < ; inline
+
 UNION: real rational float ;
 
 TUPLE: complex { real real read-only } { imaginary real read-only } ;