diff --git a/core/math/floats/floats.factor b/core/math/floats/floats.factor index b441276a88..47ecdab125 100644 --- a/core/math/floats/floats.factor +++ b/core/math/floats/floats.factor @@ -74,4 +74,6 @@ M: float prev-float M: float fp-sign double>bits 63 bit? ; inline +M: float neg? fp-sign ; inline + M: float abs double>bits 63 2^ bitnot bitand bits>double ; inline diff --git a/core/math/integers/integers.factor b/core/math/integers/integers.factor index 3cab1dd4e8..0457165fac 100644 --- a/core/math/integers/integers.factor +++ b/core/math/integers/integers.factor @@ -8,6 +8,8 @@ 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 diff --git a/core/math/math.factor b/core/math/math.factor index 81e488cb19..94a0db98c3 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -73,6 +73,8 @@ ERROR: log2-expects-positive x ; : even? ( n -- ? ) 1 bitand zero? ; inline : odd? ( n -- ? ) 1 bitand 1 number= ; inline +GENERIC: neg? ( x -- -x ) + : if-zero ( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b ) [ dup zero? ] [ [ drop ] prepose ] [ ] tri* if ; inline