fix next-power-of-2
parent
52e24115ea
commit
a06c259947
|
@ -25,11 +25,11 @@ UNION: integer fixnum bignum ;
|
|||
2dup >= [
|
||||
drop
|
||||
] [
|
||||
>r 1 shift 1 max r> (next-power-of-2)
|
||||
>r 1 shift r> (next-power-of-2)
|
||||
] if ;
|
||||
|
||||
: next-power-of-2 ( n -- n )
|
||||
0 swap (next-power-of-2) ;
|
||||
1 swap (next-power-of-2) ;
|
||||
|
||||
IN: math-internals
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ unit-test
|
|||
[ 0 ] [ -7/8 ceiling ] unit-test
|
||||
[ -1 ] [ -3/2 ceiling ] unit-test
|
||||
|
||||
[ 0 ] [ 0 next-power-of-2 ] unit-test
|
||||
[ 1 ] [ 0 next-power-of-2 ] unit-test
|
||||
[ 1 ] [ 1 next-power-of-2 ] unit-test
|
||||
[ 2 ] [ 2 next-power-of-2 ] unit-test
|
||||
[ 4 ] [ 3 next-power-of-2 ] unit-test
|
||||
|
|
Loading…
Reference in New Issue