How Is Int.from_bytes() Calculated?
I am trying to understand what from_bytes() actually does. The documentation mention this: The byteorder argument determines the byte order used to represent the integer. If byteo
Solution 1:
Big byte-order is like the usual decimal notation, but in base 256:
230 * 256**3 + 4 * 256**2 + 0 * 256**1 + 0 * 256**0 = 3859021824
just like
1234 = 1 * 10**3 + 2 * 10**2 + 3 * 10**1 + 4 * 10**0
For little byte-order, the order is reversed:
0 * 256**3 + 0 * 256**2 + 4 * 256**1 + 230 = 1254
Post a Comment for "How Is Int.from_bytes() Calculated?"