Jan-17-2024, 08:54 PM
Hello,
Sorry in advance for the likely basic nature of this question. I'm wondering how the "int.from_bytes" method returns the output that it does when it's converting input other than the escaped parts of bytes objects (see below for some examples).
These examples I understand - they're simply converting hexadecimals to decimal integers.
Thanks so much in advance for any help and have a great day.
Sorry in advance for the likely basic nature of this question. I'm wondering how the "int.from_bytes" method returns the output that it does when it's converting input other than the escaped parts of bytes objects (see below for some examples).
These examples I understand - they're simply converting hexadecimals to decimal integers.
print(int.from_bytes(b'\x0f', "little"))
Output:15
print(int.from_bytes(b'\xc0\xff\xee', "big"))
Output:12648430
print(int.from_bytes(b'\xc0\xff\xee', "little"))
Output:15663040
These examples I don't understand:print(int.from_bytes(b'1', "big"))
Output:49
print(int.from_bytes(b'Hello world', "big"))
Output:87521618088882671231069284
print(int.from_bytes(b'Helloworld', "big"))
Output:341881320660071462628452
Does it have something to do with the base system of the input and / or output - such as the particular base system the method assumes the input is expressed in? Or the base system it uses for the output? What am I missing here?Thanks so much in advance for any help and have a great day.