I used this site for conversion: https://www.binaryhexconverter.com/binary-to-decimal-converter
9223372036854775807 is represented as 0111111111111111111111111111111111111111111111111111111111111111
And a byte takes up 1 byte, which is 8 bit, so the last 8 bit is: 11111111 Converting this back to a number using the website linked above I get 255, not -1.
Please see my code.
Thank you very much for helping me out.
long l = 9223372036854775807L;
System.out.println("Value of B: " + l);
byte b = (byte) (l);
System.out.println("Value of B: " + b);
This has the following result:
Value of B: 9223372036854775807
Value of B: -1