math.functions: make it clear that 0 = is the more correct zero?.

db4
John Benediktsson 2012-08-13 08:03:54 -07:00
parent 94ad1c236f
commit ea25cde2af
2 changed files with 3 additions and 0 deletions

View File

@ -16,6 +16,8 @@ IN: math.complex.tests
[ f ] [ C{ 1.0 2.3 } C{ 1 2 } number= ] unit-test [ f ] [ C{ 1.0 2.3 } C{ 1 2 } number= ] unit-test
[ C{ 2 5 } ] [ 2 5 rect> ] 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 [ 2 5 ] [ C{ 2 5 } >rect ] unit-test
[ C{ 1/2 1 } ] [ 1/2 C{ 0 1 } + ] unit-test [ C{ 1/2 1 } ] [ 1/2 C{ 0 1 } + ] unit-test
[ C{ 1/2 1 } ] [ C{ 0 1 } 1/2 + ] unit-test [ C{ 1/2 1 } ] [ C{ 0 1 } 1/2 + ] unit-test

View File

@ -8,6 +8,7 @@ IN: math.functions
[ numerator ] [ denominator ] bi ; inline [ numerator ] [ denominator ] bi ; inline
: rect> ( x y -- z ) : rect> ( x y -- z )
! Note: an imaginary 0.0 should still create a complex
dup 0 = [ drop ] [ complex boa ] if ; inline dup 0 = [ drop ] [ complex boa ] if ; inline
GENERIC: sqrt ( x -- y ) foldable GENERIC: sqrt ( x -- y ) foldable