From a2640672d79e22ca246e9ae8d431803075bc3e89 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Jun 2009 17:47:52 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=C2=AB0.0=201.0=20^=C2=BB=20was=20returning?= =?UTF-8?q?=200=20instead=20of=200.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basis/math/functions/functions-tests.factor | 3 ++- basis/math/functions/functions.factor | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 0bdc6ce00b..e47de14dba 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -22,6 +22,7 @@ IN: math.functions.tests [ t ] [ e pi i* ^ imaginary-part -0.00001 0.00001 between? ] unit-test [ t ] [ 0 0 ^ fp-nan? ] unit-test +[ 0.0 ] [ 0.0 1.0 ^ ] unit-test [ 1/0. ] [ 0 -2 ^ ] unit-test [ t ] [ 0 0.0 ^ fp-nan? ] unit-test [ 1/0. ] [ 0 -2.0 ^ ] unit-test @@ -162,4 +163,4 @@ IN: math.functions.tests [ 2.5 ] [ 1.0 2.5 1.0 lerp ] unit-test [ 1.75 ] [ 1.0 2.5 0.5 lerp ] unit-test -[ C{ 1 2 } ] [ C{ 1 2 } 1 ^ ] unit-test \ No newline at end of file +[ C{ 1 2 } ] [ C{ 1 2 } 1 ^ ] unit-test diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 5d88eba9fa..19a8f17a0c 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -89,7 +89,7 @@ PRIVATE> : ^ ( x y -- z ) { - { [ over zero? ] [ nip 0^ ] } + { [ over 0 = ] [ nip 0^ ] } { [ dup integer? ] [ integer^ ] } { [ 2dup real^? ] [ fpow ] } [ ^complex ] From 226c76aa1fd5b1115742462d035f640896af75a2 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 11 Jun 2009 18:00:01 -0500 Subject: [PATCH 2/2] stop playing fast and loose with NaN representations in half-floats tests --- extra/half-floats/half-floats-tests.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/half-floats/half-floats-tests.factor b/extra/half-floats/half-floats-tests.factor index 15ad53d611..d026ca2933 100644 --- a/extra/half-floats/half-floats-tests.factor +++ b/extra/half-floats/half-floats-tests.factor @@ -1,4 +1,4 @@ -USING: alien.c-types alien.syntax half-floats kernel tools.test ; +USING: alien.c-types alien.syntax half-floats kernel math tools.test ; IN: half-floats.tests [ HEX: 0000 ] [ 0.0 half>bits ] unit-test @@ -7,7 +7,7 @@ IN: half-floats.tests [ HEX: be00 ] [ -1.5 half>bits ] unit-test [ HEX: 7c00 ] [ 1/0. half>bits ] unit-test [ HEX: fc00 ] [ -1/0. half>bits ] unit-test -[ HEX: fe00 ] [ 0/0. half>bits ] unit-test +[ HEX: 7eaa ] [ HEX: aaaaaaaaaaaaa half>bits ] unit-test ! too-big floats overflow to infinity [ HEX: 7c00 ] [ 65536.0 half>bits ] unit-test @@ -25,7 +25,7 @@ IN: half-floats.tests [ -1.5 ] [ HEX: be00 bits>half ] unit-test [ 1/0. ] [ HEX: 7c00 bits>half ] unit-test [ -1/0. ] [ HEX: fc00 bits>half ] unit-test -[ 0/0. ] [ HEX: 7e00 bits>half ] unit-test +[ t ] [ HEX: 7e00 bits>half fp-nan? ] unit-test C-STRUCT: halves { "half" "tom" }