Bitwise operations in Python?
Carl
phleum_nospam at chello.se
Thu Aug 18 13:21:09 EDT 2005
Dear friends,
I am currently porting a fortran program to Python but am stuck on the
intrinsic IBITS function.
Does anyone know about a replacement function for IBITS in Python?
Yours, Carl
>>>>>>>>>>>>>>>>
IBITS(I, POS, LEN)
Extracts a sequence of bits.
I
must be of type integer.
POS
must be of type integer. It must be nonnegative and POS + LEN must be
less than or equal to BIT_SIZE (I).
LEN
must be of type integer and nonnegative.
Class
Elemental function
Result Type and Attributes
Same as I.
Result Value
The result has the value of the sequence of LEN bits in I beginning at bit
POS, right-adjusted and with all other bits zero.
The bits are numbered from 0 to BIT_SIZE(I)-1, from right to left.
Examples
IBITS (14, 1, 3) has the value 7.
More information about the Python-list
mailing list