hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ??
Juha Autero
Juha.Autero at iki.fi
Tue Aug 19 03:33:05 EDT 2003
"Michael Peuser" <mpeuser at web.de> writes:
>> Two questions: What is the best way to generate bitmask of n bits all
>> ones?
>
> Why do you object to 2**n-1? This is just fine I think.
Maybe I should have said "What other ways there are to generate a
bitmask of n bits all ones?" 2**n-1 seemed like a hack since it relies
on certain properties of binary numbers, but on the other hand all
bitmask processing relies on certain properties of binary numbers.
--
Juha Autero
http://www.iki.fi/jautero/
Eschew obscurity!
More information about the Python-list
mailing list