From ea25cde2af157a5be5400f95e45da5c6537f30d3 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 13 Aug 2012 08:03:54 -0700 Subject: [PATCH] math.functions: make it clear that 0 = is the more correct zero?. --- basis/math/complex/complex-tests.factor | 2 ++ basis/math/functions/functions.factor | 1 + 2 files changed, 3 insertions(+) diff --git a/basis/math/complex/complex-tests.factor b/basis/math/complex/complex-tests.factor index 9869d0d593..57a5c8fd27 100644 --- a/basis/math/complex/complex-tests.factor +++ b/basis/math/complex/complex-tests.factor @@ -16,6 +16,8 @@ IN: math.complex.tests [ f ] [ C{ 1.0 2.3 } C{ 1 2 } number= ] unit-test [ C{ 2 5 } ] [ 2 5 rect> ] unit-test +{ 2 } [ 2 0 rect> ] unit-test +{ C{ 2 0.0 } } [ 2 0.0 rect> ] unit-test [ 2 5 ] [ C{ 2 5 } >rect ] unit-test [ C{ 1/2 1 } ] [ 1/2 C{ 0 1 } + ] unit-test [ C{ 1/2 1 } ] [ C{ 0 1 } 1/2 + ] unit-test diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index c21586f9cc..264a15d7b0 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -8,6 +8,7 @@ IN: math.functions [ numerator ] [ denominator ] bi ; inline : rect> ( x y -- z ) + ! Note: an imaginary 0.0 should still create a complex dup 0 = [ drop ] [ complex boa ] if ; inline GENERIC: sqrt ( x -- y ) foldable