please dont rip this site

Digital Logic Tutorial

Binary and Decimal Numbers

You do math with decimal numbers. Computers do math with binary numbers. Most of the time, both come to the same answer.

The first thing we need to get over is that zero is a number. Zero is a big time number that we tend to forget and ignore. Most people who work with digital logic and computers know and love zero for the major player that it truly is. If you start with zero, and NOT with one, binary numbers make a lot more sense.

Also, the way we count on our fingers is a bit... wrong. Try this: Count to 10 on your fingers, but start from zero, not from one. Point to your first finger and say "zero" then to the next and say "one" and so on until you get to your tenth finger, where you will find yourself saying "nine". Huh? Try it again. If you start with zero, your ten fingers count to 9.

Now find a marker and draw those numbers on your finger nails. Yes, do it. Draw "0" on the first finger, then "1" on the next and so on up to "9" on your tenth finger. Notice that each of your digits only has one digit on it. If you had started from "1", your tenth finger would have "10" on it which is 2 digits; "1" and "0".

dig·it /'dijit/ Noun 1. Any of the numerals from 0 to 9, esp. when forming part of a number. 2. A finger (including the thumb) or toe.

Now start from "zero" and count to "ten". Notice that you run out of fingers, but you can use your toes. Take off your shoes and socks and draw "0" to "9" on your toenails. I'm not kidding, you want to learn this don't you? Start with your first toe and first finger down, to show all zero. Then count on your fingers to nine and then move your first toe up and your second toe, the "1" toe, down. Ok, use a nail or something to keep the second toe down and the others up. Move your fingers back so that "0" is down and the others are up. Now THAT is how you should count to "10". Much better isn't it? Ok, maybe your toes hurt a bit, but you're learning...

Now I want you to imagine that you only have one finger on each hand and one toe on each foot. No, I'm not going to ask you to cut the others off, that would be silly! Just fold all your fingers and toes down and write "0" on one hand and foot and "1" on the other hand and foot. This is how computers work: This is binary.

With only your hands and feet (no fingers or toes) count from 0 to 1, then count to 2. What? you cant? Yes, you have run out of digits. What did you do last time you ran out, when you had 10 fingers and 10 toes? You moved from your hands to your feet and moved your feet from zero to one and your hands back to zero. Do the same thing now. Your "1" foot is down and your "0" foot is now up. Your "0" hand is down and your "1" hand is up. That is 2 in binary

Now for 3: Three is just the next number, so move from 0 to 1 on your hands, keeping your feet the same. You have 1 on your hands and 1 on your feet. You might want to call that 11, but it is really 3 in binary.

To count to 4 in binary, you need someone else's hands, or another set of feet, either way. The third set of digits would be at 1, the second set at 0 and the first set (your hands) would be at 0 as well. 100 is 4 in binary.

Try it in the simulator below. Push the buttons to make a number in binary and the display will show you what that number actual is in our regular decimal numbers. (or use the Falstad simulator Binary input) Below that, you can press the up and down arrows above and below the right hand digit and the lights will show you that decimal number in binary.

Notice on the top circuit, that You can't make a number larger than 15. With only 4 wires, representing 4 binary digits, 15 is the largest value we can represent.

On the bottom circuit, notice that if you put in a number greater than 15, the output is no longer correct. For example, at 16, all the output lights go out. This is an "overflow" where there are not enough lines to carry the actual value.

Outside of a computer, when writing on paper, in decimal in binary, if we need another digit, we just add it. But that doesn't work in a computer, where there are only a fixed number of wires. Overflows need to be detected and dealt with in computers.

Next

Binary Adder

Advanced

Decimal

Binary

Octal

Hex

0

0

0

0

1

1

1

1

2

10

2

2

3

11

3

3

4

100

4

4

5

101

5

5

6

110

6

6

7

111

7

7

8

1000

10

8

9

1001

11

9

10

1010

12

A

11

1011

13

B

12

1100

14

C

13

1101

15

D

14

1110

16

E

15

1111

17

F

We use multiple wires as binary digits to show numbers larger than 1. Two wires can hold a decimal number as big as 3 in binary form. That means we can hold 4 different values: 0, 1, 2, and 3. Don't forget zero! Zero counts.

3 wires can hold a number up to 7, or 8 different values.

As you look at the number of wires used in the simulation above, you can see we used 4 wires, which can actually hold a number up to 15 for a total of 16 different values. It is good to see the relationship between the number of wires, or bits, and how large a number that allows us to hold. Have you noticed that the number of different values we can hold doubles each time we add a wire? 1 wire holds 2 values, 2 wires hold 4, 3 hold 8, and 4 hold 16. It doubles each time: 2, 4, 8, 16. How many values will 5 wires hold? 8 wires? 16?

If you look at all your fingers and thumbs, you have 10 symbols or digits; from 0 to 9 which is decimal. If you look at just your thumbs, you have 2 symbols; 0 and 1 which is binary. If you look at just your fingers (not your thumbs) you have 8 symbols; 0 to 7. This last one is called Octal. It's another radix like binary or decimal.

Octal is the closest match between the decimal digits and some number of binary digits. 3 binary digits almost equal 1 decimal digit in terms of how large a number they can hold. When you count in octal, you have to go to 10 after 7, so 10 octal is actually 8 in decimal. Can you figure out what 12 octal is in decimal? How about 20? 71?

Another common radix is Hexadecimal or Hex for short. It uses 16 digits: 0-9 and A-F. When you get to 9 in hex, you keep going with A, then B, C and so on to F. It may seem weird to count in letters, but the "A" is just the same as our decimal 10; B is 11, and so on until F which is 15 in decimal. So you don't move to two digits until you get to 10 which is 16 in decimal. Can you decode 1A in hex? How about A0?

Move your mouse over the questions to see the answers.

See also:


file: /Techref/logic/bindec.htm, 11KB, , updated: 2022/3/22 21:22, local time: 2024/3/29 04:01,
TOP NEW HELP FIND: 
54.160.245.243:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://piclist.com/techref/logic/bindec.htm"> Digital Logic Tutorial: Binary and Decimal Numbers</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .