diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 3c6a32c3fa..6aacd8b26c 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -159,7 +159,7 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11 { -5.0 } [ -4.5 floor ] unit-test { -4.0 } [ -4.5 ceiling ] unit-test -{ t } [ -0.3 truncate double>bits -0.0 double>bits = ] unit-test +{ t } [ -0.3 truncate double>bits 0.0 double>bits = ] unit-test { t } [ -0.3 ceiling double>bits -0.0 double>bits = ] unit-test { t } [ 0.3 floor double>bits 0.0 double>bits = ] unit-test { t } [ 0.3 truncate double>bits 0.0 double>bits = ] unit-test diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 6def5b0558..ec19c5a54e 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -360,8 +360,10 @@ M: float truncate [ drop ] 2dip dup 0 < [ ! the float is between -1.0 and 1.0, - ! the result is +/-0.0 - drop -63 shift zero? 0.0 -0.0 ? + ! the result could be +/-0.0, but we will + ! return 0.0 instead similar to other + ! languages + 2drop 0.0 ! -63 shift zero? 0.0 -0.0 ? ] [ ! Put zeroes in the correct part of the mantissa 0x000fffffffffffff swap neg shift bitnot bitand