Largest 2^n less than x?
Other than iterating n and testing against x, is there a particular method in SAGE to find the largest 2^n less than a specified integer?
Thanks CL
add a comment
Other than iterating n and testing against x, is there a particular method in SAGE to find the largest 2^n less than a specified integer?
Thanks CL
What about using logarithms and rounding from below using the floor()
function ?
Another possibility could be to look at the size of the binary representation of your integer a
by using a.binary()
or a.bits()
.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2015-04-07 07:21:44 +0100
Seen: 144 times
Last updated: Apr 07 '15