math.functions: make -0.3 truncate return 0.0 instead of -0.0.
parent
1dceb069ad
commit
57de1f5ab0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue