hbutils.binary.int¶
CSignedIntType¶
-
class
hbutils.binary.int.
CSignedIntType
(size: int)[source]¶ - Overview:
Signed int type.
-
__init__
(size: int)[source]¶ Constructor of
CSignedIntType
.- Parameters:
size – Size of the type.
-
read
(file: BinaryIO) → int[source]¶ Read signed int value.
- Parameters:
file – Binary file,
io.BytesIO
is supported as well.- Returns:
Signed int value.
-
property
size
¶ Size of the given type.
c_byte¶
-
hbutils.binary.int.
c_byte
= <hbutils.binary.int.CSignedIntType object>¶ Alias for
c_uint8
.
c_short¶
c_int¶
-
hbutils.binary.int.
c_int
= <hbutils.binary.int.CSignedIntType object>¶ Alias for
c_int32
(in 64-bits OS).Note
Size of
c_int
is the same as that in C language, which mainly depends on CPU and OS.c_long¶
-
hbutils.binary.int.
c_long
= <hbutils.binary.int.CSignedIntType object>¶ Alias for
c_int64
(in 64-bits OS).Note
Size of
c_long
is the same as that in C language, which mainly depends on CPU and OS.c_longlong¶
-
hbutils.binary.int.
c_longlong
= <hbutils.binary.int.CSignedIntType object>¶ Alias for
c_int64
(in 64-bits OS).Note
Size of
c_longlong
is the same as that in C language, which mainly depends on CPU and OS.c_int8¶
-
hbutils.binary.int.
c_int8
= <hbutils.binary.int.CSignedIntType object>¶ - Overview:
Reading and writing signed integer with 8-bits.
- Examples::
>>> import io >>> from hbutils.binary import c_int8 >>> >>> with io.BytesIO(b'\xde\xad\xbe\xef') as file: ... print(c_int8.read(file)) ... print(c_int8.read(file)) ... print(c_int8.read(file)) ... print(c_int8.read(file)) -34 -83 -66 -17 >>> with io.BytesIO() as file: ... c_int8.write(file, -34) ... c_int8.write(file, -83) ... c_int8.write(file, -66) ... c_int8.write(file, -17) ... print(file.getvalue()) b'\xde\xad\xbe\xef'
c_int16¶
-
hbutils.binary.int.
c_int16
= <hbutils.binary.int.CSignedIntType object>¶ - Overview:
Reading and writing signed integer with 16-bits.
- Examples::
>>> import io >>> from hbutils.binary import c_int16 >>> >>> with io.BytesIO(b'\xde\xad\xbe\xef\x12\x34\x56\xf7') as file: ... print(c_int16.read(file)) ... print(c_int16.read(file)) ... print(c_int16.read(file)) ... print(c_int16.read(file)) -21026 -4162 13330 -2218 >>> with io.BytesIO() as file: ... c_int16.write(file, -21026) ... c_int16.write(file, -4162) ... c_int16.write(file, 13330) ... c_int16.write(file, -2218) ... print(file.getvalue()) b'\xde\xad\xbe\xef\x124V\xf7'
c_int32¶
-
hbutils.binary.int.
c_int32
= <hbutils.binary.int.CSignedIntType object>¶ - Overview:
Reading and writing signed integer with 32-bits.
- Examples::
>>> import io >>> from hbutils.binary import c_int32 >>> >>> with io.BytesIO(b'\xde\xad\xbe\xef\x12\x34\x56\xf7') as file: ... print(c_int32.read(file)) ... print(c_int32.read(file)) -272716322 -145345518 >>> with io.BytesIO() as file: ... c_int32.write(file, -272716322) ... c_int32.write(file, -145345518) ... print(file.getvalue()) b'\xde\xad\xbe\xef\x124V\xf7'
c_int64¶
-
hbutils.binary.int.
c_int64
= <hbutils.binary.int.CSignedIntType object>¶ - Overview:
Reading and writing signed integer with 64-bits.
- Examples::
>>> import io >>> from hbutils.binary import c_int64 >>> >>> with io.BytesIO(b'\xde\xad\xbe\xef\x12\x34\x56\xf7') as file: ... print(c_int64.read(file)) -624254242407928354 >>> with io.BytesIO() as file: ... c_int64.write(file, -624254242407928354) ... print(file.getvalue()) b'\xde\xad\xbe\xef\x124V\xf7'
-
-
-