Are hexadecimal numbers ever negative?

phoenix picture phoenix · Apr 29, 2011 · Viewed 46.1k times · Source

Are hexadecimal numbers ever negative? If yes then how?
For binary you would have signed and unsigned.
How would one represent them in Hex? I need this for a hex routine I am about to embark upon.

Answer

Andrew Cooper picture Andrew Cooper · Apr 29, 2011

Yes. For example you'd have the following representations in signed 32-bit binary and hex:

Decimal: 1
 Binary: 00000000 00000000 00000000 00000001
    Hex: 00 00 00 01

Decimal: -1
 Binary: 11111111 11111111 11111111 11111111
    Hex: FF FF FF FF

Decimal: -2
 Binary: 11111111 11111111 11111111 11111110
    Hex: FF FF FF FE

As you can see, the Hex representation of negative numbers is directly related to the binary representation.