Hexadecimal Notation
Binary Notation is useful in computing since it represents values using the smallest possible units of info
However, it is not very useful for human comprehension
Binary values are, on average, three times longer than their decimal counterparts
Binary values are difficult to visually parse
We do not have the vocabulary to describe binary values separately from their decimal counterparts
Ideally, we would like a way of representing values that gives us benefits like being easier to read and is short than binary notation.
Decimal notation fits some criteria, but we would like this representation to have a direct relationship so it can easily convert to binary, and decimal notation does not fit in that criteria
Hexadecimal notation (base 16) - a way of representing numerical values with a direct correlation to their binary counterparts, while still remaining convenient for human use
whereas binary notation expresses value using powers of 2 (and decimal uses powers of 10), hexadecimal notation expresses value using powers of 16.
For example, in decimal notation 34 equates to 52 (4×16^0 = 4, 3×16^1 = 48, 4 + 48 = 52)
However, we have a problem:
Binary notation contains two unique digits
Decimal notation contains ten unique digits
Therefore, to properly express values in hexadecimal notation, we will need sixteen unique digits
Since the number systems contains only ten unique digits, we will need to borrow some other symbols
By breaking the binary value into nibbles (chunks of 4 bits), we can see a direct relationship between binary and hexadecimal
ex. 7A = 0111 1010
ex. F8 = 1111 1000
ex. CE = 1100 1110
Because of this, hexadecimal appeals to all the criteria:
easy to read and understand
short than binary
uses a familiar vocab
Has a direct relationship with binary, such that we can easily convert between them
To avoid confusion with strings (ex. FEED is a valid hex number), hexadecimal numbers are often marked with an 0x to indicate they are in base 16.
ex. 0×7F1A3B56
Now, you can clearly distinguish between 10 in decimal and 0×10 in hexadecimal. Likewise, we can distinguish between ‘BEEF’ as a string and ‘0xBEEF’ as a hex value