diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index b673a02b70..138d557c0f 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -407,7 +407,7 @@ HELP: number HELP: next-power-of-2 { $values { "m" "a non-negative integer" } { "n" "an integer" } } -{ $description "Outputs the smallest power of 2 greater than " { $snippet "m" } ". The output value is always at least 2." } ; +{ $description "Outputs the smallest power of 2 greater than or equal to " { $snippet "m" } ". The output value is always at least 2." } ; HELP: power-of-2? { $values { "n" integer } { "?" "a boolean" } } diff --git a/core/math/math-tests.factor b/core/math/math-tests.factor index 1a729fcef4..fb25886e70 100644 --- a/core/math/math-tests.factor +++ b/core/math/math-tests.factor @@ -86,3 +86,10 @@ IN: math.tests { -0x3fffffffffffffff } [ 0x3ffffffffffffffe >bignum bitnot ] unit-test { -0x4000000000000000 } [ 0x3fffffffffffffff >bignum bitnot ] unit-test { -0x4000000000000001 } [ 0x4000000000000000 >bignum bitnot ] unit-test + +{ 2 } [ 0 next-power-of-2 ] unit-test +{ 2 } [ 1 next-power-of-2 ] unit-test +{ 2 } [ 2 next-power-of-2 ] unit-test +{ 4 } [ 3 next-power-of-2 ] unit-test +{ 4 } [ 4 next-power-of-2 ] unit-test +{ 8 } [ 5 next-power-of-2 ] unit-test