math.functions: ~ now raises an invalid operation FP trap if one of the inputs is NaN

db4
Slava Pestov 2009-09-29 23:41:08 -05:00
parent 86118ce56a
commit 0a29e64287
3 changed files with 7 additions and 1 deletions

View File

@ -29,6 +29,7 @@ set-default-fp-env
[ t ] +fp-overflow+ [ 1.0e250 1.0e100 ] [ * ] test-fp-exception-compiled unit-test
[ t ] +fp-underflow+ [ 1.0e-250 1.0e-100 ] [ * ] test-fp-exception-compiled unit-test
[ t ] +fp-overflow+ [ 2.0 100,000.0 ] [ fpow ] test-fp-exception-compiled unit-test
[ t ] +fp-invalid-operation+ [ 2.0 0/0. 1.0e-9 ] [ ~ ] test-fp-exception-compiled unit-test
! No underflow on Linux with this test, just inexact. Reported as an Ubuntu bug:
! https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/429113

View File

@ -44,8 +44,14 @@ IN: math.functions.tests
[ 4.0 ] [ 10000.0 log10 ] unit-test
[ t ] [ 1 exp e 1.e-10 ~ ] unit-test
[ f ] [ 1 exp 0/0. 1.e-10 ~ ] unit-test
[ f ] [ 0/0. 1 exp 1.e-10 ~ ] unit-test
[ t ] [ 1.0 exp e 1.e-10 ~ ] unit-test
[ t ] [ -1 exp e * 1.0 1.e-10 ~ ] unit-test
[ f ] [ 1/0. 1/0. 1.e-10 ~ ] unit-test
[ f ] [ 1/0. -1/0. 1.e-10 ~ ] unit-test
[ f ] [ 1/0. 0/0. 1.e-10 ~ ] unit-test
[ f ] [ 0/0. -1/0. 1.e-10 ~ ] unit-test
[ 1.0 ] [ 0 cosh ] unit-test
[ 1.0 ] [ 0.0 cosh ] unit-test

View File

@ -141,7 +141,6 @@ M: real absq sq ; inline
: ~ ( x y epsilon -- ? )
{
{ [ 2over [ fp-nan? ] either? ] [ 3drop f ] }
{ [ dup zero? ] [ drop number= ] }
{ [ dup 0 < ] [ neg ~rel ] }
[ ~abs ]