Integers
Constants
| Action |
Code |
Details |
|
Min int
|
|
|
|
Max int
|
|
|
Create
int() throws ValueError if the input cannot be parsed
| Action |
Code |
Details |
|
Define integer
|
|
Cannot contain decimal values or result will be float. |
|
Define integer from scientific notation
|
|
Cast is needed otherwise result is float |
|
Binary integer
|
|
-0b10 (-2) |
|
Hex integer
|
|
e.g., -0xF (-16) |
|
Integer from string
|
|
|
|
Integer from hex string (base 16)
|
|
e.g., DEADBEEF |
|
Integer from string with base determined by prefix
|
|
Base 10 by default, base-16 for 0x, base-2 for 0b |
|
Integer from string according to locale
|
|
|
|
Unsigned integer from bytes
|
int.from_bytes(x, byteorder='big')
|
|
|
Signed integer from bytes
|
int.from_bytes(x, byteorder='big', signed=True)
|
|
Test
| Action |
Code |
Details |
|
Is integer
|
|
|
Convert
| Action |
Code |
Details |
|
To string
|
|
|
|
To string, with comma as thousands separator
|
|
|
|
To hex string
|
|
Format: `[sign] ['0x'] integer |
|
To bytes
|
x.to_bytes(8, byteorder='big')
|
OverflowError is raised if the integer is not representable with the given number of bytes |
|
To bytes
|
x.to_bytes(8, byteorder='big', signed=True)
|
|
|
Count to byte array (mutable)
|
|
|