Skip to content Skip to navigation Skip to collection information

OpenStax-CNX

You are here: Home » Content » Microcontroller and Embedded Systems Laboratory » Binary and Hexadecimal Notation

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • TI MSP430 display tagshide tags

    This collection is included inLens: Texas Instruments MSP430
    By: Texas Instruments

    Comments:

    "Basic introduction to microcontroller-based embedded systems development. Includes structured laboratory exercises in the following areas: assembly programming, C language programming, peripheral […]"

    Click the "TI MSP430" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Binary and Hexadecimal Notation

Module by: CJ Ganier, Patrick Frantz. E-mail the authors

Summary: Explains binary and hexadecimal numbers and how to convert them.

Because of the nature of the digital systems, it is necessary to be able to represent numbers as being composed of only 1’s and 0’s. Ordinarily we represent numbers using the characters 0-9, and this notation is called base 10 or decimal notation. Using only the characters 1 and 0 is called binary notation or base 2 (because there are only 2 characters to represent the number instead of 10). Converting integers between these two systems is easy. In base 10 each decimal place represents the number of a certain power of 10. Thus the one’s place(10^0), 10’s place(10^1), 100’s place (10^2) etc. In base 2 each place represents a corresponding power of 2.

To convert a base 10 number into its base 2 form, begin at the 2’s place of the largest power of two smaller than the base 10 number you are converting. This will be the highest 1 digit of the base two number. Now see if the next smaller power of 2 is larger than the reminder of your base 10 number. If it is the next place in the base two number is a 0 if its smaller, subtract the power of two from the base 10 number and put a 1 in the next place. Repeat this until you have reached the 2^0 place. To convert back, go through each power of two place in the binary number and multiply it by the corresponding power of two. Sum these products to get the decimal version of the binary number.

Example 1

steps in converting to base 2

  1. 721512=209 721512 209 so the first bit is 1×291 29
  2. 209<256209256 so the second bit is 0×28028
  3. 209128=8120912881 so the third bit is 0×27027
  4. 8164=17 8164 17 so the fourth bit is 1×26126
  5. 17<32 1732 so the fifth bit is 0×25025
  6. 1716=1 1716 1 so the sixth bit is 1×24124
  7. 1 <81 8 so the seventh bit is 0×23023
  8. 1<414 so the eigth bit is 0×22022
  9. 1<212 so the ninth bit is 0×21021
  10. 11=01 1 0 so the tenth bit is 1×20120
  11. thus the conversion: 721=1011010001 721 1011010001

This method works backwards also, starting from 10110100011011010001 and expanding each digit by its appropriate exponent.

Exercise 1

What is 293293 in binary? What is 11100011110001 in decimal?

Solution

293=100100101293100100101 and 1110001=1131110001113

Hexadecimal is another numerical convention that is really base 16. It uses the characters 0-9 for its first 10 numbers and the letters A-F to represent 10 through 15. Conversion between it and base 10 numbers proceeds the same as base 2 substituting powers of 16 for powers of 2. However, the important use of hexadecimal numbers is as an abbreviation for binary; because binary representation of large numbers becomes quite long. When programming, hexadecimal numbers should be prefaced with 0x to indicate that they are hexadecimal numbers rather than variable names etc. Thus 14 is a decimal number in C, and 0x14 is a hexadecimal number (actually equal to 20 in decimal). Below is a the list of expansions for hexadecimal to binary to decimal.

binary to hexadecimal equivalence

  • 0000=0=00000 0 0
  • 0001=1=10001 1 1
  • 0010=2=20010 2 2
  • 0011=3=30011 3 3
  • 0100=4=40100 4 4
  • 0101=5=50101 5 5
  • 0110=6=60110 6 6
  • 0111=7=70111 7 7
  • 1000=8=81000 8 8
  • 1001=9=91001 9 9
  • 1010=A=101010 A 10
  • 1011=B=111011 B 11
  • 1100=C=121100 C 12
  • 1101=D=131101 D 13
  • 1110=E=141110 E 14
  • 1111=F=151111 F 15

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks