Int¶
-
class
Int¶ Bases:
pygears.typing.uint.IntegerFixed width generic signed integer data type.
- Generic parameters:
N: Bit width of the
Intrepresentation
- Parameters:
val – Integer value to convert to
Int
Intis a generic datatype derived fromInteger. It represents signed integers with fixed width binary representation. Concrete data type is obtained by indexing:>>> i16 = Int[16]
-
__int__()¶ int(self)
-
__len__()¶ Returns the number of bits used for the representation
>>> len(Integer[8](0)) 8
-
bit_length()¶ Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
-
classmethod
decode(val)¶ Creates Integer object from any int-convertible object val.
>>> Integer[8].decode(0xffff) Integer[8](255)