Binary Lesson 6 – Notating Base

September 4, 2014

lesson06If we see the numbers,

  • 100
  • 100
  • 100

how do we know which is decimal, which is binary, and which is hexadecimal? All three numbers look alike because they use the same digits, 0 and 1, but all three represent different values in different number systems. Surely, there must be a way to avoid ambiguity, right?

Indeed there is.

Identifying Binary and Decimal Numbers

Binary 100 and decimal 100 do not express the same value because 100 in binary converts to the decimal value 4 and 100 in decimal is simply one hundred.

There is no way to differentiate between 100 (base 2) and 100 (base 10) by themselves outside of context. To avoid ambiguity, there are three ways to specify the base when combining number systems.

1.  Specify the base in parentheses:  100 (base 2) or 100 (base 10) or 100 (hex)
2.  Append a lower-case b for binary, d for decimal, or h for hexadecimal after the number.
100b (binary) 100d (one hundred in decimal) 100h (256d in hex)
3.  Use subscript notation denoting the base after the number.

  • 1002   = Base 2, binary
  • 10010  = Base 10, decimal
  • 10016  = Base 16, hexadecimal

Notes

Hexadecimal. Hexadecimal has an extra notation: 0x. The following are four different ways to denote hexadecimal:

  • 0xff
  • ffh
  • ff16
  • ff (base 16)

No Base Assumes Decimal. If no base is specified, we can usually assume decimal unless noted as another number system from context. For example, 100 by itself would mean 100d, not 100b unless the text is specifically referring to binary. However, even if the text is talking about binary, it is common practice to denote binary 100 as 100b anyway to avoid confusion.

1123 = 1,123 (one thousand, one hundred twenty-three in decimal).

This contains non-binary digits, so we know that this is not a binary number. However, we have no way of knowing which base this represents since there are other number systems that use these digits. It could be base 5, base 8, base 16, or something else as long as it is base 4 or greater.

(1,123 contains the digit 3, which is the highest digit of base 4. We know that 1,123 must be a value written in base 4 or greater since base 3 and lower do not contain the digit 3.)

Because base 10 is the most common number system, we can assume base 10 unless noted.

Examples

  • 11000b = 24d
  • 11000d = 11,000d (eleven thousand in decimal)
  • 0110d  = one-hundred, ten in decimal (an unusual format designed for trickery that is better written as 110d)
  • 1100h = 4,352d (four thousand, three-hundred, fifty-two in decimal)
  • 11002 = 1100b
  • 1,23410 = 1,234d
  • 110016 = 1100h
  • 1,100 (base 10) = 1,100d = 1,10010
  • 100 (base 16) = 100h
  • 100 (base 2) = 100b = 4d
  • 0xFF = FFh = ffh = 0xff = 255d = 11111111b

Convert 10100001b to decimal

128  64  32  16   8   4   2   1
  1   0   1   0   0   0   0   1
128 + 32 + 1 = 161 decimal

 

Convert 00011100 (base 2) to decimal

128  64  32  16   8   4   2   1
  0   0   0   1   1   1   0   0
16 + 8 + 4 = 28

 

Convert 101001102 to decimal

128 + 32 + 4 + 2 = 166 decimal

If the place values are memorized, we can perform low-bit conversions mentally.

In the three examples above, the binary base was notated differently.

 

Practice

Specify the number system of each value.

  1. 100d
  2. 1
  3. oxfe2222ef
  4. 23 (base 2)
  5. 1616
  6. 666h
  7. 100010
  8. 100,0002
  9. 10011001 111111002
  10. 100110012 111111002
  11. 1001100110 111111002

Answers

  1. Decimal.
  2. Decimal. No base was specified, so we assume decimal even though these are binary lessons.
  3. Hexadecimal.
  4. Oops! A trick question! This is invalid because we cannot use the digits 2 and 3 in base 2.
  5. Hexadecimal. Converts to 22d and 10110b.
  6. Hexadecimal. A common gray-color shorthand for 0x666666 that is used in cascading style sheets (CSS).
  7. 1,000 in decimal.
  8. Binary, but not quite correct. We do not use commas to separate groups in binary. Instead, we break up long binary strings of digits into groups of four or eight for readability. 100,0002 should be written as 1000002.
  9. Binary. We see two groups of eight for readability, but it is one binary number despite the space between them. This is not common due to possible ambiguity. Are these two separate numbers with the first being a decimal 10,011,001 and the second a binary 11111100? To avoid confusion, this would be better written as one long string of digits despite the resulting bulkiness: 10011001111111002.
  10. Binary. However, these are definitely two separate numbers, not one, single number. Each has a specified base, so we know that two different numbers, 100110012 and 111111002 are intended. If we wish to denote a single 16-bit value, it is best to write 10011001111111002. This avoids any possible confusion. For extremely long binary numbers, such as 32-bit, 64-bit, and 128-bit values, hexadecimal is preferred.
  11. Decimal first, Binary second. These are two separate numbers listed one after another. The first number, 1001100110, is decimal, and it should have been written with commas as 10,011,00110 in order to avoid being mistaken as a binary number since the subscript is in smaller print. The second number is binary, and it is written correctly.
Advertisements

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: