Jump to content

science Can you read/count Binary (like a computer)?


Splashee

Recommended Posts

Like the title say:

Can you read Binary numbers?

 

If you can, you can respond with yes, or a 1, or whatever you like! However, if you can't maybe you will be able to after you read this post (by me, the lousy teacher):

Spoiler

Why would you ever need to read binary numbers? What are binary numbers? What are they good for?

 

If you are like me, and never use your brain, and only use a calculator. Then you should know that the calculator do everything in binary. That means, everything you can do in a calculator, no matter if it is in the palm of your hand, a cell/smart phone, a computer software, the numbers and operations on those numbers are done in binary ones (1) and zeros (0).

If you are a math person, you might even know that binary is a base-2 numeral system, while our usual method of counting is in base-10. We have 10 fingers, so it makes sense!

 

First task, for testing. Bring up your calculator (you need Windows for this). Press and hold the Windows key on your keyboard and press the R key to make the Run dialog appear. Type calc and press Enter.
Click the View menu and choose Programmer. You can no longer your the decimal point, as that is not allowed with binary numbers. Only whole numbers are allowed.
Notice the list of options saying Hex, Dec, Oct, and Bin... By default, Dec is selected. This means you are in Decimal mode (Base-10). Type any number, and select another mode to translate the number. For example, type 5 and select Bin (Binary), and the number will be translated to 101. Press C (Escape key on the keyboard) to clear the calculator output to 0.

Now, from 0, in Bin mode, press 1 (1 on the keyboard/numpad) and the plus sign + (+ on the keyboard/numpad), and then click the equal sign = over and over (Enter key). Notice how there is a pattern of 1's and 0's being displayed? It is somehow repeating the same pattern over and over. Try to recognize this pattern, remember it.

Here is the pattern:
 

Spoiler

The two first digits:

00
01
10
11

and repeat, forever!

Binary numbers are represented by ones (1) and zeroes (0). Obviously, the zero (0) by itself is zero. So that one is easy!
So what is a single 1 (one)? Well, it is 1 of course!

So you are counting up by 1, when you are pressing the equal sign on your calculator (after the initial 1 + that is). So what happens if you do subtraction instead? What pattern will you see?

Second task, in the calculator cleared to 0 (press C (Escape key)) in Bin mode. Now press 1 (1 on the keyboard/numpad), and then click the equal sign = over and over (Enter key). What pattern do you see, well:

Spoiler

The two lowest digits:

00
11
10
01

and repeats, forever!

So, you have the same pattern of digits, only counting backwards. It is still the same pattern though!

 

 

So let's look into the pattern. The first number (counting upwards) is zero, then one, then ten, and lastly eleven, before repeating. If going in the opposite direction (counting downwards), the first number is zero, then eleven, then ten, and lastly one, before repeating.

 

Good, so you got this far. You can actually end here, since you know how to convert between decimal and binary numbers in the calculator, you now can say yes to this topic's question and move on!
But if you are more interested, get ready for more:

 

 

So, in binary, when you have reached 1, it is the same as when you have reached 9 in decimal. You need to carry to the next digit if you add 1.

If you have 9, and add 1, you will get 10. And in binary, if you have 1, and add 1, you will get 10.
In decimal, if you have 99, and add 1, you will get 100. And in binary, if you have 11, and add 1, you will get 100.
 

But decimal 100 means 100 to us humans. In binary, to represent that same number, it is not as simple. The calculator will give you this value for 100, if you convert from decimal to binary: 1100100. If you were to count up by 1, a hundred times, you would get the same number (don't do it, you would probably miss by one, and screw up, and waste your time).

 

So, by now you might be confused about what digital means, and bits, and bytes and all those technical words. We are still not even bringing that up! Binary is a way of counting in base-2. We can do that on paper, as easy as any other math you can do on paper, and you don't need the digital world to do it. We can remove the calculator all together, and do the math by hand! (pen and paper that is), and that, my friends, is analog, not digital!

 

How to add two binary numbers together. Addition. You have seen this one before, in school!
 

Spoiler


 10
+ 1
___
 11

So, if you have 10 (ten) in binary, and you add 1, you will get 11 (eleven). Remember the pattern you learnt. After 10 (ten) comes 11 (eleven).

 

But did you also remember that after 1 (one) comes 10 (ten)? How is that possible? Now, remember what I said about carrying over to the next digit? Like in decimal how 9 plus 1 becomes a 10 (a new digit)? When you do that addition on paper, you usually put the carry somewhere, right? And then you add that carry to the next digit slot. So in binary a 1 (one) plus 1 (one) becomes a 10 (ten), and you have to put that carry somewhere, in just the same way. The rules of addition still applies!



(1)
 __
  1
+ 1
___
 10

In parenthesis, you see the carry. It is added to the next digit, which is implicitly 0 (zero) in this case. And if you get confused about 1+1 being 0, then you would be equally confused about (decimal) 9+1 also becoming 0 in the same situation. In the same digit slot, if you reach the maximum number, and add 1 to it, it will go back to 0. Binary just keeps doing it so often it makes you think more about it.

 

Okay, so this is where I usually get in trouble. But I am sure you have better understanding of math than I do. If not, the calculator is still a very nice tool to have, to correct any mistakes. Let's try to add a number which requires a cascade of carries:



(11)
____
  11
+ 11
____
 110

Notice, how that first carry needs to be added to a 1, which causes the second carry? But we still have 1 left, which stays! Yea, this somehow makes sense to you guys? If it does, you are a math genius. I am only here to teach you Binary, not to be good at math, so there!

 

Well, to see what happens in a similar case with decimal, just to understand the whole addition and carry. Let's do one of those:



(11)
 ___
  99
+ 11
____
 110
 
 
 [Note, this is decimal and not binary! Still addition!]

So again, you see that adding 1 to 9 causes the carry, but we still have 1 left in that digit slot. It is the same rules. If you do addition differently, you should be able to adapt to binary pretty easily by now.

Yay, so subtraction time! This is where people like me who hates math, starts loving math. Because subtraction doesn't exist in binary! Next!
... Wait, hold up? Doesn't exist? Let's go into details:

 

Spoiler

 

Okay, so we cannot talk about subtraction without introducing negative numbers. In binary, we only have whole numbers. No decimal point. No fractions. But we do have negative numbers, IF WE WANT TO!
So any binary number can be a negative number, if we define what a negative number is. And we do so by introducing the "sign". For every digit in binary, we have either ones (1) or zeros (0), but what if we define one of those digits to be a sign (a negative sign, you know the - sign). Of course we would make that sign the first digit in the sequence of digits, just like we would do to represent negative numbers in decimal, like for example:
-9

The digit in front of 9 is the sign, obviously. That sign is also there in binary, only it is represented by 1 instead. Funny story, when you think about it, is the sign in decimal actually a 9 that has been repainted into a minus sign? Who knows? All I can say is, in binary, it works this way!

 

In order to define a sign, we must define the number of digits, that is the maximum amount of zeroes (0) or ones (1) we can use to represent a number. Let's say four digits, just to make it easy for our minds. If we choose anything less, it will be too little to test on, and if we choose more, it will take forever for us to get anywhere! Four is our maximum digits. As an example in decimal, the maximum number we could store in four digits is 9999. In binary however, the maximum number we could store in four digits is 1111.

 

Okay, so now when we know there are four digits to out numbers, we can always say that zero is 0000. In binary, there is no "minus zero", only zero (or positive zero). Don't get confused. Who does anything with the value zero anyways?
So how do we find the negative number of a positive number? We do need negative numbers, and if we have a positive number already, and we want to put that sign in there, how do we do that? Well there is a rule to help us, and it is called two's complement. Yea, I am not going to say that again. Instead, I will show you how to do it.

 

We have to introduce the first bitwise operation. You heard it right, bits, as in computer bits. The operation is called NOT, and it will turn every bit in your number from a one (1) to zero (0), or zero (0) to a one (1). Examples:

1001 NOT equals 0110.
0110 NOT equals 1001.
1100 NOT equals 0011.
0000 NOT equals 1111.
1111 NOT equals 0000.

 

You can find NOT (Spelled Not) in the calculator. It is only available in Programmer view. You can use it even in Dec mode, though you will see it does make a number negative, it doesn't do the right negative number from the same positive number. It is not meant to do that! It is meant to inverse bits, and it is the first step into making a negative number.
Remember our little test with patterns earlier? When we were counting upwards, it started with zero, and then one, ten, and lastly eleven before repeating? When we were counting downwards, we had the same pattern backwards? Well, not exactly the same, then it would have been starting at eleven, ten, one, and lastly zero before repeating, but it didn't do that. The result you were expecting from that kind of bit pattern is what you'll get with the NOT operation. A symmetrical bit pattern.
Instead, you got zero first, then eleven... And so on. So how do you get zero from using NOT on the value zero, and you cannot use subtraction as it doesn't exist? Look what this does:

0000 NOT equals 1111.

The value zero turned into a bunch of ones. To get back to zero, without using NOT again (using NOT twice is like not using NOT at all) is to add one to the ones, just look here:



(x111)
 _____
  1111
 +   1
 _____
  0000

We get zero back, because we added all the carries (plural of carry, I am not that good at English, or math), and the x is the carry we discard because we only allow four digits to represent a binary number.

So the rule of two's complement is to do a NOT operation on your number and adding one. That will convert your number from positive to negative, and negative to positive. Try it out in the calculator, translate the numbers from Bin to Dec to see that it works, and you don't need four digits to make it work. It always works! That's two's complement.

 

So subtraction doesn't exist. However, adding a negative number is the same as subtraction. So let's do a test then. In decimal, we know that 4 - 7 = -3. We also know that in decimal, 4 + -7 = -3. We didn't do any subtraction, but we still got the same result. We added a negative number. So let's convert the decimal numbers to binary, and for our convenience, we will only convert the numbers that we'll expect to see from the result. Here is a translation (use the calculator if you must, but remember to only use the lowest 4 digits of the binary number, when you convert from decimal to binary):

4 decimal = 0100 binary.
7 decimal = 0111 binary.
3 decimal = 0011 binary.

 

And now, we need to negate 7 and 3, using two's complement to get our negative 7 and negative 3 for our test. Remember, first NOT and then add 1! So for 7 decimal, invert all the bits in the binary value 0111 into 1000, and add 1, which equals 1001:

-7 decimal = 1001 binary.

 

And the same for 3 decimal, invert all the bits in the binary value 0011 into 1100, and add 1, which equals 1101:

-3 decimal = 1101 binary.

 

Just a quick note, how the highest digit is 1 in the negative numbers! That's our sign bit! For anyone who likes, you can replace that 1 with a - sign, but remember, it is required in our addition to actually work!

 

Now, to complete this mess. We do the addition on the binary numbers:



 0100 (4 decimal)
+1001 (-7 decimal)
_____
 1101 (-3 decimal)

Yes, that is subtraction. It is done by negating the positive number, and then adding the bits. Because the top bit is a minus sign, but also a number, addition works on it, and just like the pattern we learned, it will repeat, over and over again.

[LOL you have reached a state where I am going to edit this post, in order to not lose my progress. If you want to know more, come back later. Maybe I will have fixed a few typos as well by then! Please do not quote this post when you reply, as the test will change!]

 

Oh my, you made it this far? Did you look inside the spoilers? I hope you did!

 

Next up is multiplication... (And yes, it exists):
 

Spoiler

Before we begin with multiplication, we can already understand that multiplication is just adding the same number, over and over, so many times that the multiplication as been fulfilled. Yay! Done.
No. Not only is that very annoying for large numbers, but also slow. And computers have more important things to do than repeating the same operation over and over......... nah, I got that wrong. Instead think of it like this, if you use a cheap pocket calculator to calculate 8 times 222, that thing would take seconds to add 8 twohundredandtwentytwo times. So that is not the case.

 

Instead, let's introduce another bitwise operation. Yay! This one is called logical shift left. It is simple. If you have a number of let's say four digits, 0010. And you shift it to the right by one digit, introducing a new 0, and discarding the digit that is being pushed out, the number would become 0100. Here are a few examples:

0010 LSL equals 0100.
0001 LSL equals 0010.
0011 LSL equals 0110.
0110 LSL equals 1100.

 

And don't be confused now, as the bits that are being shifted outside the four digits are discarded:

 

1100 LSL equals 1000.
1111 LSL equals 1110.

 

So what is this good for? Shifting bits one digit to the left is the same as multiplying that binary number with 2. I'll say it again, this is the same as multiplication with the value 2.
Do another shift on the same number, and you multiply that number with 2 again, meaning you just did a multiplication with the value 4. And so on. I am not going to go into how multiplication works, since I kinda hate math as much as the rest of you guys. Well, just for the sake of it and because I want to see if I am right:

Decimal 8 times decimal 2 equals decimal 16.
Decimal 16 (result of previous operation) times decimal 2 equals decimal 32.

 

So is decimal 8 times decimal 4 equals decimal 32, then I was correct.... ..... um..... Okay, I was correct!

 

So let's try this with logical shift left then. First, let's convert the values we want to test, from decimal to binary (using the calculator if you need to). I'll do it here:

8 decimal = 001000 binary.
16 decimal = 010000 binary.
32 decimal = 0100000 binary.

 

If you can't see the logical shift left already in those binary numbers, then I don't know. I think I did a bad example. By shifting once, you multiplied with 2, and if you were to shift two times, you would multiply with 4. I also added some zeroes in front so we wouldn't confuse these numbers with any negative numbers.

 

So multiplying with non-power-of-2 numbers. Well, it is kinda complex. I really don't want to get this far, as I haven't yet told you how to read binary yew (which was the topic to begin with). Let's just say you want to multiply any number with 12. 12 is not a power-of-2 number. That means we have to use logical shift left and addition!


[Note: Decimal]
Um, 1 * 8 + 1 * 4 = 12. I just had to check. Any number. That means (x * 8 + x * 4) = (x * 13). So 4 is a power-of-2 value, and so is 8. All we need to do is take any binary number, duplicate it, and do shifts on them, and add them together.

 

Let's choose a number that we need to multiply with decimal 12. We choose decimal -3. Remember, that evil negative number in the subtraction example? It was 1101 in binary. The result is expected to be decimal -36, which exceeds a four digits binary number. What to do??? We need more digits to represent the numbers, and it so turns out we need exactly seven digits to represent decimal -36. Fun fact, we only need six digits to represent positive decimal 36, as the extra digit is for the minus sign. So let's negate decimal 36 which is binary 0100100. Do a NOT and then ADD 1: 0100100 NOT equals 1011011, and ADD 1, equals 1011100 (-36 decimal).
And decimal 3 with seven digits is 0000011. Do a NOT and then add 1: 0000011 NOT equals 1111100, and ADD 1, equals 1111101 (-3 decimal).

 

Okay, let's take decimal -3, and shift it two times (multiply by 4) to the left:

  1. 1111010
  2. 1110100

And do the same with the duplicate value decimal -3, only shift it three times (multiply by 8) to the left:

  1. 1111010
  2. 1110100
  3. 1101000

Now, add those two numbers together to get decimal -36, and by that, it would complete our multiplication by decimal 12:


(z1) 
  _______
  1110100
 +1101000
 ________
  1011100 (-36)
  
  
[Note: the z above is a carry which is outside our seven digits, and is discarded]

Yes, that did in fact result in decimal -36. Again, the top digit (the seventh digit) is the sign bit, telling us they are negative numbers. If you want the positive numbers, do the two's complement on them, that is NOT and ADD 1.

 

And that's my limits of how multiplication is done. I am sure there are much smarter ways to do them, but they are not used by me (while programming games).

 

And lastly, division. This is actually a difficult matter. I don't have all the answers on this one. While you can do the reverse of the multiplication, it is still out of reach for me to solve all cases:
 

Spoiler

Again, let's introduce another bitwise operation. This one is called logical shift right. It is simple. If you have a number of let's say four digits, 0010. And you shift it to the left by one digit, introducing a new 0, and discarding the digit that is being pushed out, the number would become 0001. Here are a few examples:

0010 LSR equals 0001.
0001 LSR equals 0000.
0011 LSR equals 0001.
0110 LSR equals 0011.

 

But there is one catch! Introducing a 0 is all fine if we are dealing with only positive numbers. But the sign bit is so important in negative numbers, that we need to duplicate it if it exists. So we introduce 1 instead, which is called arithmetic shift right:

1010 ASR equals 1101. (The negative number 1010 is still a negative number 1101 when it is shifted one digit to the right, if we introduce another 1)
1111 ASR equals 1111. (Same as above, note how 1 is introduced, and 1 is discarded, making it do nothing!)

 

So, all we need to do to divide a value by 2, is to use arithmetic shift right. Well, except for that weird minus one, which divided by 2 still yields .... -1.

 

Divide also introduces the "Divide by Zero" exception, as well as the ability to read the reminder, the so called modulo operator. None of which I can do with binary numbers. It is possible to do division by right shifts, and modulo by bit-masking. But that is out of the scope of this topic.

 

So, if you made it this far, it is only one more thing to learn then. How to read binary numbers. When you have read this one, you don't even need to reply to this topic as you will know by default, the answer:
 

Spoiler

[In decimal]
Okay, so it has all to do with the position of the digits. Remember that! The first position is 1. The second position is 2, then 4, then 8, then 32, then 64, then 128, then 256, then 512, then 1024, then 2048, then 4096, then 81?? Yes I keep these values in my head up to that point, then I use a calculator if I need more.

 

So the number:

11001011011 (decimal 1627, or it might be decimal -421 if you decide the top bit is a sign bit)

Read from right to left. If it is a 1, then multiply with the numbers I said above. Then add to the result:

First digit is 1, so result is 1...
Second digit is 1, so 2 is added to the result making the result total 3 so far...
Third digit is 0, so skip (else you would have added 4 to the result)...
Fourth digit is 1, so 8 is added to the result making the result total 11 so far...
Fifth digit is 1, so 16 is added to the result making the result total 27 so far...
And next digit is 0 so skip (else you would have added 32 to the result)...
And next digit is 1, so add 64 to the result making the total 91 so far...
And next digit is 0, so skip (else + 128)...
And next digit is 0, so skip (else + 256)...
And next digit is 1, so add 512 to the result, total 603...
And the last digit is 1, so add 1024, and the final total result is............................... 1627.

 

So what about that -421? How do you get it? Sadly, the sign bit is constructed from doing two's complement on the (positive) value 421 and limiting the amount of digits to exactly eleven. That's the only case when that is true.

 

 

So, now, you should be able to read binary numbers without using a calculator.

Edited by Splashee
If there are spelling errors, or any problems with the math, send a private message, and I will fix any issues
  • Brohoof 5
Link to comment
Share on other sites

Why use calculator? updc471.png

calculator Z2I68tp.png NOT EPIC

100 (D) => 1100100 (B)

> 100 | 0
   50 | 0  /|\
   25 | 1   |
   12 | 0   |
    6 | 0   |
    3 | 1   |
    1 | 1

no calculator r9Quzru.png EPIC

checkmate calculator users rVzK55c.png

 

jk

  • Brohoof 3

genshin_icon_wish.png Playing Genshin Impact? Come join the club! genshin_icon_wish.png
trixie trotting gif.gif   >>>   genshinclubicon.png.1483d2aa1271776b0086

Link to comment
Share on other sites

I used to be able to. My sophomore year of high school I took Liberal Arts math, which was basically a little bit of everything (a good half of the class was really just useless information, but I was lazy and only needed one more math credit, so I took that instead of Trig). We learned a bunch of different number systems (including ancient Egyptian, for some reason), and binary was one of them. I completely forgot how to read it over the years and have no reason to learn again, though. Just one of the many things from school I didn't need or retain.

  • Brohoof 2

Rainbow Dash Fanatic

"You stroll down memories of younger, brighter times 'cause you never realize what you've got till you leave it all behind." ~ dBPony

"So we’re here at the end, did we teach you well, my friend? Don’t look so sad to see us go, after the rain comes rainbows." ~ Princewhateverer

"Darlin' you'll be okay." ~ Vic Fuentes

Link to comment
Share on other sites

  • 1 month later...

A tiny bit, but really not much. I DID do Computing for GCSE, but I forgot a lot of it...:yeahno:

  • Brohoof 1

𝔗𝔥𝔢𝔯𝔢'𝔰 𝔞𝔩𝔴𝔞𝔶𝔰 𝔬𝔭𝔭𝔬𝔯𝔱𝔲𝔫𝔦𝔱𝔶 𝔱𝔬 𝔡𝔬 𝔱𝔥𝔢 𝔣𝔯𝔦𝔢𝔫𝔡𝔩𝔶 𝔱𝔥𝔦𝔫𝔤!

slightlybigscone.png.d32b27b7260a958d4c29ef2633c4ea89.png

 

 

Link to comment
Share on other sites

I can, but its more likely I will use hex - most stuff I do is in it, rather than binary.

  • Brohoof 1

ᚾᛖᚹ ᛚᚢᚾᚨ ᚱᛖᛈᚢᛒᛚᛁᚴ - ᚦᛖ ᚠᚢᚾ ᚺᚨᚦ ᛒᛖᛖᚾ ᛞᛟᚢᛒᛚᛖᛞ

image.png.1d67db17f637a25cb8070c016012d5cf.png

Link to comment
Share on other sites

13 minutes ago, SparklingSwirls said:

“There are 10 kinds of people in this world, those who understand binary, and those who don’t” :P 

and those who realise base 3 is also an option :)

  • Brohoof 1

ᚾᛖᚹ ᛚᚢᚾᚨ ᚱᛖᛈᚢᛒᛚᛁᚴ - ᚦᛖ ᚠᚢᚾ ᚺᚨᚦ ᛒᛖᛖᚾ ᛞᛟᚢᛒᛚᛖᛞ

image.png.1d67db17f637a25cb8070c016012d5cf.png

Link to comment
Share on other sites

Ummmmm…..binary? Like a freaking computer?? The best teacher on earth couldn’t teach me computer stuff, so no, I don’t speak it and I never will. My head hurts just thinking about it.  

Link to comment
Share on other sites

  • 1 month later...

I can actually multiply binary numbers now, which was something I only speculated about before. I have the details in my blog.

I am also thinking about cover the dreaded division, which has some very unique stuff to it.

Link to comment
Share on other sites

In high school (I think) one of the classes I was in taught us how to read it. I actually took to it quickly and was able to read it well. However, that was years ago and I don’t remember how to anymore.

  • Brohoof 1
Link to comment
Share on other sites

  • 3 weeks later...

What does everypony think of the binary counting system? I'm learning a lot about it in my computer classes, though what would it be like if it was the only counting system we had? Would you want to always write a number like 10 as 1010, or 55 as 110111? Maybe we should just use hex all the time, and write those numbers as A and 37. :twi: (I sure hope I got the number conversion right :lie:)

  • Brohoof 2

img-35348-1-post-8308-0-40473900-1426345427.png
Link to comment
Share on other sites

What do I think of binary? Well I think it’s interesting that ponies can apparently type in it:

23169787-31BE-4767-8CC0-D35EFA8AF00F.thumb.png.a2a193dfd58a246d54406a99c6e470fd.png

Otherwise I think it’s interesting, if a little difficult to wrap my brain around it’s workings.

  • Brohoof 3

 

Signature_Forums.png.dd2a654d7faa42c09ea06c44865a3c2a.png

Check out my artwork any time: http://shadobabe.deviantart.com/
"OMG; You are such a troll. XD" - PathfinderCS

Link to comment
Share on other sites

Duodecimal (base 12) is clearly the best number system. 12 is evenly divisible by 2, 3, 4 and 6, and most of our measurements are based on 12 or multiples of 12 already (12 inches in a foot, 24 hours in a day, 12 months in a year, etc).

  • Brohoof 3

826287943_lyrasignature2.png.aca7e8f78d1af1c7c0ca36c743dcb69b.png

Signature by @Mellow Mane

Link to comment
Share on other sites

Just now, Princess of Hearts 💛🧡 said:

Honestly it just adds a level of complexity to maths that I really would not want to bother with lool

Not really, dear Princess. It's not like that at all. While math is complex and stupid (really annoying stupid. 3.14159265whatever stupid), binary actually has several functions that are helpful, especially when writing video games, or working with computers.

Things like wrapping, and unsigned values. It's a world full of awesome and Super Mario and stuff :squee: You must love it!

  • Brohoof 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...