This demonstrates how to convert decimal numbers to binary and vice versa. A 5-bit number is used in this demonstration.
Step 1: Setup
This app needs no peripherals.
Step 2: Running and using the app
Navigate to the BinaryNumbers app and press Button B to run. There are three modes controlled by successive presses of Button B as follows.
The first screenshot on the left below is the default screen. The user can display the 5-bit binary equivalent of any given decimal number up to 31. The decimal number is selected by using Buttons C & D – each increment and decrement the decimal number by 1.
Note that a 5-bit binary number can represent 32 different values of any measurement because “0” is a value in binary.
In the second screenshot, the first binary digit, called a “bit” and reading from right to left, is 2 raised to the power 0 – which is decimal 1. The second is 2 raised to the power 1 – which is 2; the third is 2 raised to the power 2 – which is 4; the fourth is 2 raised to the power 3 – which is 8; and the fifth is 2 raised to the power 4 – which is 16.
These decimal numbers (1,2,4,8,16) are shown alongside the five binary digits. Add the decimal numbers together in the places where the “1” is showing in the binary number to obtain its decimal equivalent. In the second screenshot at top right above, binary 00101 is (0x16) + (0x8) + (1×4) + (1×1) =5
Pick a random Decimal number (Left hand screenshot below) and write it down separately in binary. Check with”Show” (right hand screenshot)
Pick a random Binary number (Left hand screenshot below) and write it down separately in decimal. Check with”Show” (right hand screenshot).
- What are the decimal number corresponding to a sixth, seventh, and eighth bit?
- What is an 8-bit digital “word” called?
- Why does an 8-bit digital “word” hold a special place in computing?
- How many levels can an 8-bit “word” represent?
- Set up variables
- Display static text
- Change the mode of operation between showing and solving numbers
- Adjust the numbers according to the mode using the C and D keys
- Random decimal, user solves binary
- Random binary, user solves decimal
- Compute the binary number from the decimal (default)