Reputation: 80
In Java for example:
int i = 171;
(byte) i; // will return -85
Is there a way to replicate this behavior in Python? I've already tried a bunch of things but I can't seem to replicate how it works in Java.
Upvotes: 0
Views: 59
Reputation: 80
Apparently, this is how it's done:
int.from_bytes(bytes([171]), byteorder='big', signed=True)
Upvotes: 1