Binary and Two's Complement

  Рет қаралды 11,794

Gary Explains

Gary Explains

Күн бұрын

Computers use binary, a way to represent numbers using just zero and one. How does it work? How can you add binary numbers? Can binary handle negative numbers? Please let me explain!
Twitter: / garyexplains
Instagram: / garyexplains

Пікірлер: 79
@1MarkKeller
@1MarkKeller 6 жыл бұрын
*GARY!!!* *Good Morning Professor!!!* *Brilliant lesson again, as always!*
@GaryExplains
@GaryExplains 6 жыл бұрын
MARK!!!
@funmeister
@funmeister 6 жыл бұрын
I love the way you explain things, and how you explained this. Finally, a good, clean and clear explanation! Thank you!
@vinayakmakhija6681
@vinayakmakhija6681 6 жыл бұрын
Great video Professor. Please make a video on Hexadecimal too.
@fuzz33594
@fuzz33594 6 жыл бұрын
Professor Sims - I have depleted available superlatives. Really appreciate your work.
@ed4wg380
@ed4wg380 4 жыл бұрын
"0 0 0 1 and because of the 1 0 you don't carry the 1 and add the 0 0 0 0 therefore 9". Me, 16 hours into this all-nighter: Oh kayyy...
@dtvking
@dtvking 6 жыл бұрын
Binary & octal I still use today in its raw form with RS485 & 422 networks at work, soon to be taken over with IP. Nice explanation Gary, many thanks
@richwillis8794
@richwillis8794 3 жыл бұрын
Teaching an important subject and making it easy. 👍👍👍👍👍👍
@GaryExplains
@GaryExplains 3 жыл бұрын
Glad you liked it
@AKASHSOVIS
@AKASHSOVIS 5 жыл бұрын
Thank you very much Gary sir; this video was really helpful in my studies. Please can you continue this on further, maybe a lecture series on Digital Electronics. The way you explain is really simple and absorbing.
@aceflamez00
@aceflamez00 6 жыл бұрын
This channel is about to blow up thank you for mentioning it on the Android Authority channel :)
@supernova4168
@supernova4168 Ай бұрын
Thanks
@DanielCCM
@DanielCCM 6 жыл бұрын
Oh how you took me back to the 90's! I miss those theory lessons! THANKS GARY!
@nabinp
@nabinp 6 жыл бұрын
Karnaugh Map Next?
@daddyblk5239
@daddyblk5239 6 жыл бұрын
Already had a general knowledge of, but learned more watching, Thanks!
@anastasiyan44
@anastasiyan44 11 ай бұрын
best explanation so far, thank you!
@GaryExplains
@GaryExplains 11 ай бұрын
Glad it was helpful!
@alenkruth
@alenkruth 6 жыл бұрын
That was a quick brush up of higher secondary stuff😎🔥
@noonhotmailh1
@noonhotmailh1 6 жыл бұрын
That's very nice info im hoping this channel becomes viral.. it will.. keep going!
@user-kt5qt7vw2v
@user-kt5qt7vw2v 5 жыл бұрын
Excellent explanation through visual aid.
@eckligt
@eckligt 6 жыл бұрын
I think an alternative way of explaining two's complement is that the most significant column (128 in your examples) gets turned into a -128 column instead. Is this mathematically the same? Edit: So if you come along and have your number, and it happens to be positive, and you want to represent it, you look at the most significant column and see that the column is negative, and you say "no, can't have any of that". Then you go on to the second most significant column, and see if your number is greater than the number that column represents, and if it is, you chalk up a 1, otherwise you chalk up a 0, and then you move through the rest of the columns like that, subtracting the values represented by those columns you put down a 1 at, until you reach the end. If you come along with a negative number, and you see the most significant column, you know that it's going to be the only way of representing a negative number so you chalk up a 1 there, subtracting the value represented by the most significant column (effectively adding the absolute value of the most significant column) before you move to the second most significant column, and the process continues in the same way as in the case where the number was originally positive.
@GaryExplains
@GaryExplains 6 жыл бұрын
What you describe with using the last bit to go from +128 to -128 is called using a "sign" bit, it is different to two's compliment.
@eckligt
@eckligt 6 жыл бұрын
Using a sign bit is interesting, because it is often the first suggestion people have for representing both negative and positive numbers in a computer. But it's good to point out its downsides, firstly that -0 and +0 end up being distinct, which is different from maths, and furthermore wastes one bit combination, so a byte would be limited to -127 to +127. Also, (and here I'm speculating) computer hardware would need to use branching to handle positive and negative numbers separately. With two's complement, essentially the hardware doesn't need to know or care about whether a bit pattern is intended as a signed or unsigned number. The hardware has an addition operation that works equally well for both cases. It's up to the compiler (or interpreter) for some programming language to translate the number into the appropriate bit pattern, so all distinct handling of unsigned, positively-signed and negative-signed numbers happens ahead of time, making execution fast. That being said, I'm pretty sure what I described is the same as two's complement. Notice that the most significant bit in what I described is not a sign bit, but represents -128. If you add all the other positions, 64+32+16+8+4+2+1, this equals 127, so if you want to represent -1, you would first take -128 and then add 127, i.e. putting a 1 in all eight position in the byte. If you want to represent -128, you can do that, it's 1 followed by seven 0's. And you can represent +127, as a 0 followed by seven 1's.
@abaundwal
@abaundwal 5 жыл бұрын
Amazing explanation !!
@ImranAramKhan
@ImranAramKhan 6 жыл бұрын
keep it up sir i m expect more about these binary mul div and signed binary number multi n its very good.
@adamnawaz
@adamnawaz 6 жыл бұрын
Waiting for next one
@hassankhawla4701
@hassankhawla4701 6 жыл бұрын
Best explanation
@randomgyandu
@randomgyandu 6 жыл бұрын
Thanks Gary !
@aravindraj5792
@aravindraj5792 6 жыл бұрын
Thanks for the video
@caesarstorm2743
@caesarstorm2743 Жыл бұрын
update: after watching the video 3 times ive realsed the 128 is negative. i would suggest on the video this is highlighted when usg the table. like i said its just a suggestion but overall great video. Hi Gary, First of all, thank you for a great video. I found it really helpful, but when you went on to negative number's I was lost me. Can you please do another video breaking the explanation down further. I'm currently studying a cyber degree and this topic is what I'm covering however I just can't get my head around it. Please help!!!! thanks Garyno
@aestheticworldwide3250
@aestheticworldwide3250 4 жыл бұрын
Thankyou a bunch man!
@itsrohanism
@itsrohanism 6 жыл бұрын
Thanks I was Having 2's compliment In My Semesters. 🤘🏼
@avaneeshtiwari7624
@avaneeshtiwari7624 6 жыл бұрын
Rohan Singh hey but this was already breifly explained in class 11
@1MarkKeller
@1MarkKeller 6 жыл бұрын
Rohan Singh He's not called the Professor for nothing!
@itsrohanism
@itsrohanism 6 жыл бұрын
Avaneesh Tiwari But I Was Not Having Any IT Or Electronics Subject in My 12th STD.
@avaneeshtiwari7624
@avaneeshtiwari7624 6 жыл бұрын
Rohan Singh yeah....i should have said ' if you had taken computer science as a subject...' 😂😂😂 sorry i assummed it my self
@Anime_Remastered
@Anime_Remastered 6 жыл бұрын
You're a genius!! Professor gary.
@SlideRSB
@SlideRSB 6 жыл бұрын
I still don't understand why the remaining 1 carried through to the end is okay. How is it that it can just simply be thrown out?
@raghavagarwal5435
@raghavagarwal5435 6 жыл бұрын
I once made my own system of base four
@nahbicris
@nahbicris 6 жыл бұрын
This video couldn't be published in a better time, I was a little confused about 2's complement, when I saw this in the University.
@Eric-jt9nj
@Eric-jt9nj 6 жыл бұрын
It would be great to see how similar calculations are performed by the quantum processor.. Please
@StrikeFreedom1920
@StrikeFreedom1920 6 жыл бұрын
Very interesting stuff Gary Sensei!!
@sanket7402
@sanket7402 6 жыл бұрын
Sir, can you make a video on Intel Extrem Tunin Utility software. I saw a video in which one guy reduced a cpu voltage about -120mV and concluded that by reducing upto certain voltage there is decrease in 3-4 degree celcius temperature of cpu. I m getting confused at this moment that how the heck cpu temperature gets reduced by undervolting the cpu?
@wdora930
@wdora930 6 жыл бұрын
know i hope you was my profesor back then.. binari must be very easy...
@americanswan
@americanswan 6 жыл бұрын
Please plan. SQRL is coming very very soon and you WILL need to "Explain" it!!!
@ayoubzoubeidi8052
@ayoubzoubeidi8052 6 жыл бұрын
gary please explain to us "project treble"
@centuriomacro9787
@centuriomacro9787 6 жыл бұрын
Now I got it, thx
@stalinsubbiah3238
@stalinsubbiah3238 4 жыл бұрын
Bit means 0 and 1 them for example 64bit Operating System why we are considering 18446744073709551615 decimal equivalent. what is the meaning of 64bit and how it helpful to computer
@Ryuseigan
@Ryuseigan 6 жыл бұрын
Can you make a video on unlocking bootloader's How you need to apply for unlocking permission for different brands. Why you need to do so. etc. The whole custom ROM,root package!
@227mateo
@227mateo 6 жыл бұрын
Wow!! Amaizing!
@harshdeepbhatia8644
@harshdeepbhatia8644 6 жыл бұрын
And also sir how is -7 different from 249, how does our system know this?
@tsmwebb
@tsmwebb 6 жыл бұрын
At some point a programmer decides how large a container to use and if it will hold just positive numbers or both positive and negative numbers. Some languages are fairly explicit and, for example, you might have signed and unsigned 8 bit integer types to choose from. Other languages hide the details. But ultimately both length and signed or unsigned need to be agreed on so that the data can be interpreted as intended.
@harshdeepbhatia8644
@harshdeepbhatia8644 6 жыл бұрын
tsmwebb I got some of that. Thank you
@GaryExplains
@GaryExplains 6 жыл бұрын
You need to move from 8 bits to 16 bits to hold the numbers.
@tsmwebb
@tsmwebb 6 жыл бұрын
You're welcome. As Gary points out with 8 bits (one byte) you can represent a number line of length 256. That is, there are 256 distinct values in a byte (2^8). Typically you would have the values represent the numbers 0 to 255 (unsigned) or -128 to 127 (signed). So, 249 is too large to fit in a signed byte. You could code -7 and 249 into signed 9 bit integers. That's not a common data type. A signed 16 bit integer would be the conventional choice when working with numbers in that range. However you store it, there's no way to know just looking at the string of bits that it is supposed to represent a signed or unsigned integer. That's not coded into the data itself. The programmer needs to keep track of what the data represents.
@harshdeepbhatia8644
@harshdeepbhatia8644 6 жыл бұрын
tsmwebb thanks now I have understood it!! 🤩🤩👍👍
@avaneeshtiwari7624
@avaneeshtiwari7624 6 жыл бұрын
Its eazy
@ericvela4087
@ericvela4087 6 жыл бұрын
But Gary! The -7 in binary also represents a 249 decimal, how would the computer know if it was a -7 or a 249?
@GarySims
@GarySims 6 жыл бұрын
Eric Vela Yes that is a problem, so the number max number when using 2s complement is halved. That is why computer languages like C have the idea of signed and unsigned variables.
@VV-xt7fj
@VV-xt7fj 6 жыл бұрын
Why does the carry if any in the left most bit disappear? I mean why it isn't accounted?
@GaryExplains
@GaryExplains 6 жыл бұрын
There is a mathematical explanation/proof, but the simplest way to think about it is this: To get the minus number you need to invert the bits which means that the bits of the left will always be 1, even if you use 64-bits or more. This means that after you have dealt with the actual usable bits there will still be a carry (i.e. there always be a 1 + 1 carry 1) and the carry one will be recurring, it will go on forever! Take any of the examples I gave for 8 bits and extend to 16, 32 or 64 bits and you alway end up with 1 + 1 carry 1 somewhere. What is more complex is detecting an actual overflow. What if you do (-128) + (-128) then for 8 bits you get 0 (not -256, which requires 9 bits) and an overflow rather than a carry!
@VV-xt7fj
@VV-xt7fj 6 жыл бұрын
Gary Explains correct me if I'm wrong, we can't represent +128 as an 8 bit number whereas we can represent -128 as an 8 bit number by convention
@GaryExplains
@GaryExplains 6 жыл бұрын
That is right. The range is -128 to +127, for 8 bits. So (-128) + (-128) is possible in 8 bits but gives an overflow.
@elviraeloramilosic9813
@elviraeloramilosic9813 6 жыл бұрын
Great! 👍🏻👍🏻👍🏻
@sanjay764
@sanjay764 6 жыл бұрын
If we represent -7 as 11111001 then how to represent 249 in binary?
@GaryExplains
@GaryExplains 6 жыл бұрын
To represent -7 and 249 you would need switch to 16 bits.
@sanjay764
@sanjay764 6 жыл бұрын
Gary Explains will make video on it?
@GaryExplains
@GaryExplains 6 жыл бұрын
I have added it to my TODO list!
@avaneeshtiwari7624
@avaneeshtiwari7624 6 жыл бұрын
Could u please explain different types of virus
@harshdeepbhatia8644
@harshdeepbhatia8644 6 жыл бұрын
But sir why is the table going up to only 128???
@hassankhawla4701
@hassankhawla4701 6 жыл бұрын
harshdeep bhatia each digit represents a bit. With 8 columns in the table we reach 8 bits, that's 1 byte. I hope I've helped you.
@harshdeepbhatia8644
@harshdeepbhatia8644 6 жыл бұрын
Hassan Khawla it sure did and what about 32 bit and 64 bit. Are they same?
@johnnydark6876
@johnnydark6876 6 жыл бұрын
100101
@ZeeAlEidAhmadRana
@ZeeAlEidAhmadRana 6 жыл бұрын
First
@bloodonyx
@bloodonyx 6 жыл бұрын
what is carry omg
@naresh1024
@naresh1024 6 жыл бұрын
Am really confused
@GaryExplains
@GaryExplains 6 жыл бұрын
Doh! That isn't what is meant to happen!!!! Can I help?
@fero___3005
@fero___3005 2 жыл бұрын
still unable to understand nobody in KZbin explains it well SIMPLY WASTE mind sucks with Binary
Twos complement: Negative numbers in binary
13:49
Ben Eater
Рет қаралды 1,2 МЛН
Fake watermelon by Secret Vlog
00:16
Secret Vlog
Рет қаралды 6 МЛН
Люблю детей 💕💕💕🥰 #aminkavitaminka #aminokka #miminka #дети
00:24
Аминка Витаминка
Рет қаралды 1,2 МЛН
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 16 МЛН
The power of XOR - Gary Explains
5:55
Gary Explains
Рет қаралды 22 М.
What is Hyperthreading?
7:19
Gary Explains
Рет қаралды 48 М.
Pointers in C
10:09
Gary Explains
Рет қаралды 256 М.
Binary Addition and Subtraction With Negative Numbers, 2's Complements & Signed Magnitude
24:57
TCP, UDP and games like Fortnite
8:12
Gary Explains
Рет қаралды 22 М.
What is RAID (RAID 0,1,5,10)? - Gary Explains
8:44
Gary Explains
Рет қаралды 23 М.
8 bits, 16 bits, 32 bits, 64 bits and nibbles
9:07
Gary Explains
Рет қаралды 50 М.
USA Nice Olympiad Exponential Equation | Solve for X
6:38
Learncommunolizer
Рет қаралды 14 М.
5 Essential Networking Commands for Linux, Windows and macOS
13:09
Gary Explains
Рет қаралды 9 М.
Try Linux without installing it - Gary Explains
7:27
Gary Explains
Рет қаралды 21 М.
Fake watermelon by Secret Vlog
00:16
Secret Vlog
Рет қаралды 6 МЛН