In Java, byte
is a signed, and have range -128 to +127. So there is no such thing as "positive bytes" in Java.
However, if you format a (signed) byte in hexadecimal using a x
format specifier (e.g. String.format("%02x", someByte)
), it will display it as a value in the range 00
to FF
.
See https://stackoverflow.com/a/2817883/139985 for information on formatting bytes in hexadecimal.
So hexadecimal number are positive. Why?
What you are really commenting on is the convention used by that particular converter site. The site has chosen to use an unsigned representation ... because that is what is most commonly used by programmers. However it is just a convention. They could have chosen signed hexadecimal.
In the general sense, hexadecimal is a notation not a representation. It can be either signed or unsigned, depending on the context. (Just like decimal can be signed or unsigned, depending on the context.)
By contrast byte
, short
, int
, long
are Java types which have specific value ranges, and specific binary representations for those values.