Main content

## Algebra (all content)

### Course: Algebra (all content) > Unit 1

Lesson 14: Binary and hexadecimal number systems- Introduction to number systems and binary
- Hexadecimal number system
- Converting from decimal to binary
- Converting larger number from decimal to binary
- Converting from decimal to hexadecimal representation
- Adding in binary
- Multiplying in binary
- Converting directly from binary to hexadecimal

© 2023 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Introduction to number systems and binary

## Want to join the conversation?

- Why do you not have any punctuation in binary numbers like we do in base-10 numbers (for example: we write 23,567,890,653 but we don't write 111,001,010,111 or 111-001-110-011). I always find myself making mistakes in longer binary numbers (I find this nearly illegible 110110111110110001111110101) and I can't be the only one to lose track, right?(21 votes)
- The reason we put commas every three decimal places has to do with the way we name the value, ... each new comma getting a name. thousands, millions, billions, etc. So we say the number 123,456,789 : one hundred and twenty three million, 4 hundred and fifty six thousand, seven hundred and eighty nine.

In binary, we don't have those names, so commas can't help you say the number. I would argue that every 4 bits should get a space, because many (most?) people that work in binary actually write down (represent) the binary has hexadecimal because it maps cleanly (4bits/hex symbol) so you can write it faster (and use a 1/4 the number of columns)(34 votes)

- In what parts of our life do we use different number bases? Why do we use base 10 for most of the math we do? Also, why is binary useful in computers?(12 votes)
- A computer processor has (nowadays) billions of transistors. Every transistor can be seen as a "switch" that can be on or off (depending on the presence of an electric current). The on state is assigned the value "1", while the off state is assigned the value "0". Each digit is called a "bit" and 8 bits together is a "byte". The binary system was chosen because it was very simple, reliable, and efficient.

In the future we might see quantum computer systems that use all kind of crazy quantum mechanical phenomena.(29 votes)

- I tried doing this with my friend and she gave me the number 715 to translate into binary. However, I didn't find this easy can anyone help me?(5 votes)
- Chloe, you need to understand that to represent any number in binary, you'll need no go up/left to as many places as required to equal or less than the number you wish to represent, just doubling the prior place. So, going up from the 128s place where the video left off we get 256s, 512s, and then 1024s. Since 1024 is more than your example number of 715, we start by placing our most significant (I.e. Largest) bit at the 512s place, subtract 512 from 715 , and you get 203. The next lower place is the 256s, but that is more than our 203 remainder, so we put a 0 in that place and continue. Put the next bit in the 128s place, subtract that amount from 203 and the remainder now is 75. Let's see if you can take it from there?(19 votes)

- Is it true that all numbers can be represented as binary?(8 votes)
- Representing positive integers and zero is pretty straightforward in binary, however, other types of numbers require special rules and handling (that everyone must follow) to represent. These include negative numbers, decimals, fractions, complex (imaginary) numbers, etc.(9 votes)

- How would you do base 12. Like what if we had 6 fingers would it have been base 12 or would it have been decimal?(1 vote)
- If you just are curious on how to count in base twelve (Duodecimal), then here is an example of how you would count to 100.

1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, 10,

11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 20,

21, 22, 23, 24, 25, 26, 27, 28, 29, 2A, 2B, 30,

31, 32, 33, 34, 35, 36, 37, 38, 39, 3A, 3B, 40,

41, 42, 43, 44, 45, 46, 47, 48, 49, 4A, 4B, 50,

51, 52, 53, 54, 55, 56, 57, 58, 59, 5A, 5B, 60,

61, 62, 63, 64, 65, 66, 67, 68, 69, 6A, 6B, 70,

71, 72, 73, 74, 75, 76, 77, 78, 79, 7A, 7B, 80,

81, 82, 83, 84, 85, 86, 87, 88, 89, 8A, 8B, 90,

91, 92, 93, 94, 95, 96, 97, 98, 99, 9A, 9B, A0,

A1, A2, A3, A4, A5, A6, A7, A8, A9, AA, AB, B0,

B1, B2, B3, B4, B5, B6, B7, B8, B9, BA, BB, 100(14 votes)

- Why is there a zero only above 8 and 16?(7 votes)
- The numbers were just digits of the overall number, and he's putting it above the dashes so it shows that they represent the number.(1 vote)

- At2:30, Sal talks about the base-10 system that uses 10 symbols. In view of that, how could we classify the Roman numeral system? It has no 0, but a 10 (X). Also it doesn't have 10 different symbols (I-V-X-L-C-D-M) to express numbers. Is it still considered to be base-10 since it uses multiple of 10s? Thank you for your answers.(5 votes)
- Most sources (but not all) I've seen classify it as base-10, at least in the sense you mention that powers of ten (10, 100, and 1000) are named (X, C, and M); but since the system has no zero and no concept of "place value", it operates differently than positional systems such as decimal and binary.(4 votes)

- what is the binary number system?(3 votes)
- Something that can be hard at first, but you'll eventually understand it. Here is something to use to help : Theoretically, there are an infinite number of them. If you mean how many bases :P

Here are some

Base-2 Binary

Base-3 Ternary

Base-4 Quaternary

Base-5 Quinary

Base-6 Senary

Base-7 Septenary

Base-8 Octal

Base-9 Nonary

Base-10 Decimal

Base-11 Undenary

Base-12 Duodecimal

Base-15 Pentadecimal

Base-16 Hexadecimal

Base-18 Octodecimal

Base-20 Vigesimal

Base-24 Tetravigesimal

Base-25 Pentavigesimal

Base-30 Trigesimal

Base-32 Duotrigesimal

Base-36 Hexatrigesimal

Base-60 Sexagesimal

Base-64 Tetrasexagesimal

Base-120 Centovigesimal

Base-240 Duocentoquadragesimal

Base-360 Trecentosexagesimal

I hope this helps!(7 votes)

- Well, how do you represent 2 128s? Please tell me(3 votes)
- 2 × 128 = 256, so the binary string would get longer! In this case, it'd be 100000000, starting from 2^8 or 256 (as opposed to 2^7 or 128 as in the video). Similarly, if you wanted to represent 462, you'd add up 256 + 128 + 64 + 0 + 0 + 8 + 4 + 2 + 0, which would be 111001110. Intuitively, 463 would be 111001111 (you just added 1), but, less intuitively, 464 would be 111010000 (256 + 128 + 64 + 16).(7 votes)

- Why didn't you use number 16 and 8 in base 2 explanation(3 votes)

## Video transcript

- [Voiceover] For as long as human beings have been around we've been counting things, and we've been looking for ways to keep track and represent those things that we counted. So, for example if you were an early human and you were trying to keep track of the days since it last rained you might say okay let's see it didn't rain today so one day has gone by, and we now use the word one, but they might have not used it back then. Now another day goes by. Then another day goes by. Then another day goes by. Another day goes by. Another day goes by. Another day goes by, then it rained. And so when his friend comes he says, "Well, how long has it been since we last rained." Well you would say, "Well, this is how many days it's been." And your friend would say, "Okay, I think I have a general sense of that." And at some point they probably realized that it's useful to have names for these. So they would call this one, two, three, four, five, six, seven. Obviously every language in the world has different names for these. I'm sure there are lost languages that had other names for them. But very quickly you start to realize that this is a pretty bulky way of representing numbers. One it takes a long time to write down. It takes up a lot of space, and then later if someone wants to read the number they have to sit here and count. It's hard enough with seven, but you could imagine if there were what we call 27 of it, or 1000 of it. Then it would take up, possibly, a whole page and even when you counted you might make a mistake. And to solve this human beings have invented number systems. And it's something that
we take for granted. You might say, "Oh, isn't that just the way you've always counted? But hopefully over the course of this video you'll start to appreciate the beauty of a number system and to realize our number system isn't the only number system that is around. The number system that most of us are familiar with is the base 10 number system. Often called the decimal, the decimal number system. And why 10? Well probably because we have 10 fingers. Or most of us have 10 fingers. So, it was very natural to think in terms of bundles of 10 or to have 10 symbols. So however many bundles you have you can use your fingers and eventually your symbols to think
about how many there are. And since we needed 10 symbols we came up with zero,
one, two, three, four, five, six, seven, eight, nine. These 10 digits, these are our 10 symbols that we use in the base 10 system. To just give us a little bit of a reminder how we use them imagine the number 231. So, 231. 231. What does this represent? Well, what's neat about number systems is we have place value. This place all the way to the right, this is the ones place. This is the ones place. This literally means one, one. One bundle of one. So, this is one, one right over here. This right over here,
this is in the 10s place. This is in the 10s place. This three here,
literally means three 10s. So this literally means three 10s. And this two here, this two here is in the 100s place. It's in the 100s place. So, this represent two 100s. You add them together and once again I'm still thinking in base 10, you'd get 231. This is two 100s plus three 10s plus one. In our base 10 system notice every time we move to the left we're thinking in bundles of 10 of the space to the right. So, this is the ones place. You multiply by 10, you
go to the 10s place. You want to go to the next place you multiply by 10 again. You get the 100s place. If you're familiar with exponents, one is the same thing
as 10 to the zero power. 10 is the same thing as
10 to the first power. So this is the 10s place. Three tens. And 100 is the same thing as 10 to the second power. Obviously we could keep going on and on and on and on and on. That is the power of the base 10 system. So, you might be curious now. "Well, what if this wasn't 10 here? What if we did, let's just go as simple as we can. You can almost view this as a base one system. You only have one symbol right over here. But what if we went to something slightly more complex, a base two system. You'd be happy to know that not only can we do this, but the base two system often called the binary system. This is called the decimal system. The base two system often called the binary system is the basis of all modern computing. It's the underlying mathematics and operations that computers perform are based on binary. And in binary you have two symbols. You have zero and you have one. The reason why this is
useful for computation is because all the hardware that we use to make our modern computers, all of the transistors and the logic gates they either result in
an on or an off state. On or an off state. And so what we do is when you use your calculator or whatever you might be operating in base 10, but underlying everything it is doing the operations in binary. But you might say well how do we actually think in terms of binary? Well, we can construct
similar places here, but instead of them being powers of 10 they're going to be powers of two. So, let's set up some places here. So, all the way on the right two to the zero power is still one. So we can still call that the ones place. Then we can move to the left of that. We can move to the left of that. That would be two to the first power. So we could call that the twos place, and I can even write it out if I want. Twos place instead of the 10s place. Then I could keep going. Instead of this space being the 10 to the second or the 100s place, it will be the two to the second, or the fours place. And I can keep going. I encourage you actually to pause the video and try to build this out for yourself. What would this be? Well this would be two to the third, or the eights place. Notice every time we're doing this we're multiplying by two. Everytime we go to the left, just like we multiplied by 10 here. So notice everywhere you see this 10s we're now dealing with twos. Let's keep going. Let's keep going and then we can actually represent this number using binary. So, let's do that. So, this right over here I've already used that color. This right over here, this is two to the fourth. We could call that the 16s place. Then we could have -- I'll reuse some of these colors. This is two to the fifth. We could call this the 32s place. Then we can go two to the sixth. We can call that, multiply by two again, or two to the six is 64. So this is the 64s place. Tells us how many 64s we
have. Zero or one 64s. We'll see that in a second. Then we can go over here. This would be two to the seventh. That would be the 128s place. And we can obviously keep going on and on and on, but this
should be enough for me to represent this number. In future videos I will show you how to do that, but let's actually represent the number. It turns out that this number in decimal can be represented as 11100111 in binary. What does this mean? This means you have one 128 plus one 64, plus one 32, plus no 16s, plus no eights, plus one four, plus one two, plus one one. So you can see that these are going to be the same thing. Notice, this is one 128. So it's 128, plus 64, plus 32. We have zero 16s, zero eights. So we're not going to add those. Plus four, one four. Plus one two. Plus one one. And add these together, and once again when we're doing this, when I'm writing it this way I'm kind of using the number system that we're most familiar with. We're most used to
doing the operations in, but when you do it you will see that this is the exact same number as 231. This is just another representation. One isn't better than the other. The only reason why I converted this is this is what I'm used to thinking in. It's what I'm used to doing operations in. So, hopefully you find
that pretty interesting. To me, this kind of opened my mind to the power of even our decimal system. In future videos we'll explore other number systems. The most used ones, base 10 is used very heavily, binary and there's also hexadecimal where you don't have two digits or not 10 digits,
but you have 16 digits. And we'll explore those in future videos and how to convert between or rewrite the the different representations
and different bases.