diff --git a/core/math/floats/floats-tests.factor b/core/math/floats/floats-tests.factor index 70d5b765a7..e49d23e85b 100644 --- a/core/math/floats/floats-tests.factor +++ b/core/math/floats/floats-tests.factor @@ -96,14 +96,19 @@ unit-test { 39 0x1.999999999998ap-4 } [ 4.0 .1 /mod ] unit-test { 38 0x1.9999999999984p-4 } [ 3.9 .1 /mod ] unit-test -{ 39 0x1.999999999998ap-4 } [ 4.0 -.1 /mod ] unit-test -{ 38 0x1.9999999999984p-4 } [ 3.9 -.1 /mod ] unit-test +{ -39 0x1.999999999998ap-4 } [ 4.0 -.1 /mod ] unit-test +{ -38 0x1.9999999999984p-4 } [ 3.9 -.1 /mod ] unit-test { 39 -0x1.999999999998ap-4 } [ -4.0 -.1 /mod ] unit-test { 38 -0x1.9999999999984p-4 } [ -3.9 -.1 /mod ] unit-test -{ 39 -0x1.999999999998ap-4 } [ -4.0 .1 /mod ] unit-test -{ 38 -0x1.9999999999984p-4 } [ -3.9 .1 /mod ] unit-test +{ -39 -0x1.999999999998ap-4 } [ -4.0 .1 /mod ] unit-test +{ -38 -0x1.9999999999984p-4 } [ -3.9 .1 /mod ] unit-test { 0.5 } [ 3.5 0.75 mod ] unit-test { -0.5 } [ -3.5 0.75 mod ] unit-test { -0.5 } [ -3.5 -0.75 mod ] unit-test { 0.5 } [ 3.5 -0.75 mod ] unit-test + +{ 4 0.5 } [ 3.5 0.75 /mod ] unit-test +{ -4 -0.5 } [ -3.5 0.75 /mod ] unit-test +{ 4 -0.5 } [ -3.5 -0.75 /mod ] unit-test +{ -4 0.5 } [ 3.5 -0.75 /mod ] unit-test diff --git a/core/math/floats/floats.factor b/core/math/floats/floats.factor index 58f40d2ffc..9b211a0143 100644 --- a/core/math/floats/floats.factor +++ b/core/math/floats/floats.factor @@ -38,7 +38,7 @@ M: float /i float/f >integer ; inline M: real abs dup 0 < [ neg ] when ; inline -M: real /mod dupd mod [ [ - ] [ /i ] bi ] keep ; inline +M: real /mod 2dup mod [ swap [ - ] [ /i ] bi* ] keep ; inline M: float fp-special? double>bits -52 shift 0x7ff [ bitand ] keep = ; inline