diff --git a/basis/math/functions/functions-tests.factor b/basis/math/functions/functions-tests.factor index 0dec2a7345..31eeb4a0e0 100644 --- a/basis/math/functions/functions-tests.factor +++ b/basis/math/functions/functions-tests.factor @@ -173,6 +173,13 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11 { 5.0 } [ 4.5 round ] unit-test { 4.0 } [ 4.4 round ] unit-test +{ -1 } [ -3/5 round ] unit-test +{ -1 } [ -1/2 round ] unit-test +{ 0 } [ -2/5 round ] unit-test +{ 0 } [ 2/5 round ] unit-test +{ 1 } [ 1/2 round ] unit-test +{ 1 } [ 3/5 round ] unit-test + { 6 59967 } [ 3837888 factor-2s ] unit-test { 6 -59967 } [ -3837888 factor-2s ] unit-test diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index 26c5bbfc50..df994dc7b6 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -355,7 +355,7 @@ GENERIC: round ( x -- y ) M: integer round ; inline M: ratio round - >fraction [ /mod abs 2 * ] keep >= [ dup 0 < -1 1 ? + ] when ; + >fraction [ /mod dup abs 2 * ] keep >= [ 0 < -1 1 ? + ] [ drop ] if ; M: float round dup sgn 2 /f + truncate ;