Binary 2 - Two's Complement Representation of Negative Numbers

  Рет қаралды 114,224

Computer Science

Computer Science

7 жыл бұрын

This is the second in a series of computer science videos about the binary number system which is fundamental to the operation of a digital electronic computer. It covers the two's complement system of representing positive and negative integers in binary. It demonstrates how two's complement allows computers to perform subtraction operations, and explains with examples three different methods that can be used to convert negative denary numbers into binary.

Пікірлер: 147
@swedishguyonyoutube4684
@swedishguyonyoutube4684 2 жыл бұрын
I am humbled by how pedagogical, clear and efficient you are in teaching this material. I'm a former teacher switching careers to work in IT, and your videos have been incredibly helpful and instructive. Thank you very, very, much!
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
You're very welcome and thank you so much. I too switched from teaching to IT, but I came back to teaching again. :)KD
@talharashidi366
@talharashidi366 5 жыл бұрын
this is easily the best video on youtube for learning 2's complement.
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
You are very kind. Tnx :)
@ApteraEV2024
@ApteraEV2024 8 ай бұрын
I❤u 2's!!❤🎉
@oliver4003
@oliver4003 2 жыл бұрын
so I spent hours reading this section in my textbook trying to understand it with no luck. So i decided to watch this video, and 12 minutes later I fully understand the concept. Thank you so much!
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
You are very welcome - glad to help :)KD
@T3chBeatz
@T3chBeatz 5 жыл бұрын
Kevin's delivery of these tutorials is just brilliant - Thank you!
@Jayson223ad
@Jayson223ad 4 жыл бұрын
I have exam in Discrete mathematics in a few days and this is one of many topics. I knew how but not why. Thank you so much for making this so so clear. My teacher never explained the first 1 stands for -128! nor the book or notes . If all the teachers were like you the civilization would be much more advanced.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You are most welcome :)KD
@rancorjoy5412
@rancorjoy5412 Жыл бұрын
I do not think the first number stands for -128! ~ -3.856205e+215
@cesarvides9729
@cesarvides9729 4 жыл бұрын
Just when I thought I had learned an easy method, you pull out another one. This video had me on an emotional rollercoaster.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
I hope it was the exciting part of the ride. :)KD
@TheLonelyLPer
@TheLonelyLPer 3 жыл бұрын
This is hands down the best explanation I've had for 2's complement! Thank you!
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
You are very welcome :)KD
@adamyagaur9638
@adamyagaur9638 Жыл бұрын
This is learners gold. Short , crisp & clear . Thanks a lot!.
@ComputerScienceLessons
@ComputerScienceLessons Жыл бұрын
Thank you :)KD
@veryangerymanminecraftisco9048
@veryangerymanminecraftisco9048 5 жыл бұрын
Thank you so much dude, I never mange to find people who speak English on youtube that teach these sort of thing.
@potatochannel1948
@potatochannel1948 8 ай бұрын
-Sir, you are a saver, my prof at the university only gave us the two's complement method without explaining where the hell that came from . I very thankful for you sir!
@exactzero
@exactzero 3 жыл бұрын
Awesome explanation. You didn't just teach the how but also the why which is the most important of all. That last technique was mind-blowing!
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
Thanks for the comment. Delighted to help. :)KD
@xr.melissa
@xr.melissa 6 ай бұрын
Excellent video! My coworker was trying to teach this to me but it's hard to follow without strict examples, so thanks for this!
@ComputerScienceLessons
@ComputerScienceLessons 6 ай бұрын
You are most welcome :)KD
@boudieraurelien8531
@boudieraurelien8531 4 жыл бұрын
To be honnest, if you were in front of me, i'd have hug you ! You just made me so happy, i finally understood why i can use the 2's complement. I didnt understand why i had to use it. Thank you soooo much!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You are welcome. Things are much easier to understand when you know why! :) KD
@rationalsage1084
@rationalsage1084 4 жыл бұрын
This is an incredible insight, I've never understood this, my teacher only taught me the shortcut to the conversion.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Underlying concepts are important if you want knowledge that you can build upon. Thanks for the comment :)KD.
@nicestcatoutthere3221
@nicestcatoutthere3221 4 жыл бұрын
This was truly the best video on complements.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thanks for the lovely comment :) KD
@amanrubey
@amanrubey 4 жыл бұрын
your videos are simply superb. it's the same as watching some interesting documentary. I'm loving it. True Gem on the internet
@guzman-do
@guzman-do 6 жыл бұрын
What a great teacher you are, Sir!
@ComputerScienceLessons
@ComputerScienceLessons 6 жыл бұрын
You are too kind.
@cheapwisdom918
@cheapwisdom918 4 жыл бұрын
Thank you so much. Why the universities cannot make their material as easy as this? Thank you millions!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You are very welcome. Thanks for the comment. :)KD
@blank-vw2sb
@blank-vw2sb 5 жыл бұрын
AWESOME, i don't find this depth in two's complement. Really Nice
@soz824
@soz824 4 жыл бұрын
Great voice, super well made video and excellent explanation!
@sandipghoshal2122
@sandipghoshal2122 4 жыл бұрын
This so far the best video on two's compliment
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thanks for saying so. :)KD
@SuperSayiyajin
@SuperSayiyajin 5 жыл бұрын
Thanks for your playlist.
@mariiasafonova5510
@mariiasafonova5510 Жыл бұрын
Oh my Godness. It's so great explained. I find it just wondersfull so you can pause the video or watch this one more time till you get the idea...not like at the uni.
@ComputerScienceLessons
@ComputerScienceLessons Жыл бұрын
I very am glad to hear this is useful. There is a lot to be learned at university too. :)KD
@hammam92
@hammam92 5 жыл бұрын
The best video on KZbin, Thanks so much
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
Thank YOU
@ehsanmavaei5380
@ehsanmavaei5380 4 жыл бұрын
Awesome people like you who help people understand better are loveable and admirable
@LindaLawton
@LindaLawton 7 жыл бұрын
You might want to add a link to the first series in the description. Make it easier for me to go check that one out :)
@abhishekdutta8089
@abhishekdutta8089 3 жыл бұрын
Thank you sir for this wonderful lecture on representation of binary numbers.
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
You are very welcome. Thanks for commenting :)KD
@user-dv7kw8ew2q
@user-dv7kw8ew2q 9 ай бұрын
Thank you for simplifying this
@user-fg6ng7ej6w
@user-fg6ng7ej6w 3 ай бұрын
very clear explanation. cool that you presented 2 ways of dealing with it
@ComputerScienceLessons
@ComputerScienceLessons 2 ай бұрын
Thank you :)KD
@thimalifernando7164
@thimalifernando7164 4 жыл бұрын
Awesome explanation. Thank you!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You are very welcome. :)KD
@SusmitMohan
@SusmitMohan 7 жыл бұрын
Really very impressive work. Thanks a lot.
@ComputerScienceLessons
@ComputerScienceLessons 7 жыл бұрын
Tnx :)
@deedewald1707
@deedewald1707 2 жыл бұрын
You are confident and capable to teach complex concepts !
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Thank you. I've been doing it for nearly 40 years :)KD
@deedewald1707
@deedewald1707 2 жыл бұрын
@@ComputerScienceLessons I put this method into Excel such as your teacher skills are excellent !
@Technogrammer
@Technogrammer 7 жыл бұрын
Excellent Work Done!
@ComputerScienceLessons
@ComputerScienceLessons 7 жыл бұрын
:) Tnx
@LimeriuxasLT
@LimeriuxasLT Жыл бұрын
Awesome video!!! Thank you so much!
@ComputerScienceLessons
@ComputerScienceLessons Жыл бұрын
You're welcome, and thanks :)KD
@yangliyeh5510
@yangliyeh5510 3 жыл бұрын
Thanks a lot! Very clear!
@TheAltKryptonite
@TheAltKryptonite 4 жыл бұрын
This video is awesome, thank you!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you for the awesome comment. :)KD
@tavongampofu9561
@tavongampofu9561 2 жыл бұрын
wow really helpful i was struggling with this for a while thank you
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
You're welcome :)KD
@fatimakhan3084
@fatimakhan3084 2 жыл бұрын
Best teacher ever!!!
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Wow - thanks :)KD
@monjasonsteng7861
@monjasonsteng7861 8 ай бұрын
Thank you. This was great!
@ComputerScienceLessons
@ComputerScienceLessons 7 ай бұрын
You're most welcome :)KD
@ThePandaGuitar
@ThePandaGuitar 6 жыл бұрын
Fascinating!
@mmmpz2298
@mmmpz2298 10 ай бұрын
You safe me from failed the test😭 thank you so much😭
@theonesongchannel9513
@theonesongchannel9513 4 жыл бұрын
Just Beautiful!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you :)KD
@user-gd6il5zb8l
@user-gd6il5zb8l 4 жыл бұрын
Very good video, sir.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you kindly :)KD
@lumennganje2721
@lumennganje2721 4 жыл бұрын
wonderful. thanks so much. God bless you
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
You are very welcome :)KD
@astheffander_alexander
@astheffander_alexander 3 жыл бұрын
Got stuck because of the "online class" didn't help me.... But this video help sooooooo muchhh... Thanks!!! 😭
@HealthConsciousUpdates
@HealthConsciousUpdates 4 жыл бұрын
Thanks sir It's too much useful video👍👌 Love this video from Pakistan
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Thank you :) KD
@williamtylerwillis6417
@williamtylerwillis6417 Жыл бұрын
Thank you!
@ComputerScienceLessons
@ComputerScienceLessons Жыл бұрын
You're welcome :)KD
@abdullateefjabasa1656
@abdullateefjabasa1656 2 жыл бұрын
How amazing you are!
@mahmoudbasha4838
@mahmoudbasha4838 Жыл бұрын
sir great work i spent a week to try to understand this topic but thanak to u it's done.. i wanna know sir what is the program u using to make these effects in the videos
@NoName-tj8dm
@NoName-tj8dm Жыл бұрын
Thanks for the great video. I am confused how system will be able to identify that left most bit is -128 of the bit is 1
@idensoneltume627
@idensoneltume627 4 жыл бұрын
I was mind blown 🤯
@DigitalGuruLK
@DigitalGuruLK 6 жыл бұрын
what is the maximum negative number in two's complement... how it represent large negative numbers....?
@ComputerScienceLessons
@ComputerScienceLessons 6 жыл бұрын
That's where floating point binary comes to the rescue
@fadhlyrafi
@fadhlyrafi 10 ай бұрын
3:09 how about 2s complement table for 16 bit binary?
@MusaYmc
@MusaYmc 5 жыл бұрын
you are a saint
@indikajayasinghe9579
@indikajayasinghe9579 3 жыл бұрын
best of best
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Thank you :)KD
@Kenzo-0-
@Kenzo-0- 5 жыл бұрын
Ty a lot
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
You're welcome
@akshaybodla163
@akshaybodla163 4 жыл бұрын
Im really confused about binary addition. I have a few questions that i hope you can answer, thanks! 1) At 10:03 why is there a subscript of 1 at the last zero? 2) And for -122 in binary why does the addition of 0 and 0 in the two's place create a 1? 3) When is the result a 0 or 1 when adding bits
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
When we perform a similar calculation in base ten, we add pairs of digits and, if necessary, we carry a digit. In the example below, 6 + 9 is 15 so we write down 5 and carry 1. The 1 is then added to 5 + 8. 4 5 6 +7 8 9 ___1___ 5 _______ In base ten, 1+1 = 2. We represent 2 in binary as 10, so 1+1 = 10. In my video, I write down the 0 and carry the 1. The green bits are the bits that are carried. In my example for -122, the the 1 that was carried from the previous operation is added to 0+0. I just haven't shown the carry bits this time. I hope this helps. will will make a quick video on how to add binary numbers together soon. KD
@v380riMz
@v380riMz 3 жыл бұрын
Bruh this becomes so easy when you know that MSB should be -128 for negative binary numbers
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
That's the trick 💡:)KD
@voiceoverworld4036
@voiceoverworld4036 5 жыл бұрын
Where does the green 1's come from?
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
They are the carry bits. 1 + 1 = 10, so write down the 0 and carry the 1.
@kenshinhimura8708
@kenshinhimura8708 4 жыл бұрын
Thank you so much! Why can’t textbooks explain it the way you did from 0:00-7:00?
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
I'm happy to help. Thanks for the comment. :)KD
@MrMeeseeksPiano
@MrMeeseeksPiano 2 жыл бұрын
You say that I can represent up to 256 positive numbers with 8 bits but then doesn't specify wether the MSB is -128 or 128 for the exercise at 8:03? Was I supposed to guess it?
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
The left most bit is -128 as described earlier in the video. The left most bit is always a negative value with two's complement.
@kavereon
@kavereon 4 жыл бұрын
holy...moly. I understand!
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
That's music to my ears. :)KD
@rx25251
@rx25251 3 жыл бұрын
Can you please explain how the computer identifies a number as a negative number before storing it in registers in its 2s complement form ? How does the computer know the result of arithmetic operation is negative so that it can be stored in its 2s complement form.
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
Hi Ravi, a computer system stores POSITIVE numbers in two's complement as well. So that fact that it is negative, or positive, is part of the encoding. Ultimately, negative numbers come from outside the computer. When you input a negative number, you probably type a minus sign in front of it, the value you have input is then processed and stored accordingly. When it comes to arithmetic operations such as addition and subtraction, negative results take care of themselves (that's the beauty of two's complement) as you will see if you study floating point addition and subtraction later in this series. By the way, in this series, I am talking about general principles used by a range of different types of computer system. Modern PCs encode floating point numbers using the IEEE 754 standard, but the same arguments apply. :)KD
@rx25251
@rx25251 3 жыл бұрын
Thanks for the explanation! One follow-up question however - How do you represent a positive number in its two's complement form ? For example +57 in binary is 00111001 and two's complement of 00111001 is 11000111 So will the two's complement of +57 i.e., 11000111 be stored in the registers ? But the first bit is 1 which denotes a negative number. 11000111 from above is in fact binary representation of -57 and its 2's complement is 00111001 . what will be stored in the registers to represent -57 ?
@CraigEaton
@CraigEaton 5 жыл бұрын
This has confused me for YEARS and I have to teach this soon. This video just makes it so easy. I do have one question tho 1011 1011 How would one know which number is representing the negative?
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
By convention, the sign bit is the left most bit. Inside a processor register, one of the bits will be allocated as the sign bit, usually on the left, but it might vary from processor to processor. This is decided by the designers of the processor.
@user-gd6il5zb8l
@user-gd6il5zb8l 4 жыл бұрын
You just have to agree with whomever you talking to that you both use the same system. It's just like with character sets - it only works for you and your friends because you've agreed to use the same method of representation (encoding). If all of you will use different encodings (for example, like the ones before Unicode came along), you'll end up with the same binary numbers, but different interpretations of those (thus different characters).
@alexmartini8087
@alexmartini8087 3 жыл бұрын
At 11:35 for the example -44: how does the 3rd bit go from 0 + 0 = 1, but the 4th bit goes from 0 + 0 = 0?
@ComputerScienceLessons
@ComputerScienceLessons 3 жыл бұрын
With the third pair of bits there is a 1 carried from the previous pair. With the 4th pair of bits, there is no carry. Take at look at this: kzbin.info/www/bejne/iom9c6Sqm6aCprs :)KD
@phy_dude
@phy_dude 4 жыл бұрын
❤️
@barrydevine
@barrydevine 2 жыл бұрын
Does the system whereby the MSB becomes a negative (ie -128) have a name?
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
It's called 'two's complement' :)KD
@barrydevine
@barrydevine 2 жыл бұрын
@@ComputerScienceLessons In this video you seem to have 2 methods of making negative numbers: 1 - changing the MSB to -128 2 - 2's complement. Am i mistaken?
@oneminutedaily6394
@oneminutedaily6394 5 жыл бұрын
Which method is the best?
@ComputerScienceLessons
@ComputerScienceLessons 5 жыл бұрын
Two's complement lets you subtract a number by simply using addition. Sign and magnitude makes subtraction more difficult but is good for fast conversion.
@oneminutedaily6394
@oneminutedaily6394 5 жыл бұрын
@@ComputerScienceLessons thank you so much sir 👍🏼 keep it up with the good content provided. No doubt u're a hidden gem in youtube 😄
@shah144
@shah144 2 жыл бұрын
How would u do -7.5?
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Good question. You would need to use floating point binary. :)KD
@AviPars
@AviPars 2 жыл бұрын
what about positive binary to 2s complemenmt
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Same method - just put a 0 in the left-most place value. In two's complement, positive numbers always start with 0 and negative numbers always start with 1. :)KD
@Mike-vj8do
@Mike-vj8do 2 жыл бұрын
hey man, what if we are asked to do it in 6 bits
@Mike-vj8do
@Mike-vj8do 2 жыл бұрын
instead of 8 bits
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
You might. The biggest number you could encode however would be 63 (64 possible values including 0). Perhaps there is an embedded system out there that only needs to work with integers up to 63. Some types of processor might allocate 6 bits of the current instruction register to the operation code, which means a maximum of 64 commands in the instruction set (as you'll see if you start looking into hardware architecture and low level code). :)KD
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
see below
@user-fi4zx3eb4k
@user-fi4zx3eb4k Ай бұрын
im from chile, if is -32'768 for 16-bit binary numbers, i would stay it as -32'768 since doing two's complement of -32'768 does nothing.
@Redheadredification
@Redheadredification 4 жыл бұрын
I love you
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Love U 2 KD
@ghalibazad5961
@ghalibazad5961 3 жыл бұрын
How did you subtract 38 from 90...can you explain? At 2:09 .....
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Column subtraction in base 10 is explained here www.bbc.co.uk/bitesize/topics/zy2mn39/articles/zc78srd :)KD
@ghalibazad5961
@ghalibazad5961 2 жыл бұрын
@@ComputerScienceLessons thanks
@osianpetts556
@osianpetts556 Жыл бұрын
11:59, is what you're looking for Osh
@milestailsprower4555
@milestailsprower4555 2 жыл бұрын
127 is possible in 8 bit twos complement.
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
Indeed it is. The range is from -128 to 127 :)KD
@Democracy_Manifest
@Democracy_Manifest 2 жыл бұрын
Why this was published on April Fool's day I'll never know. Great video tho
@ComputerScienceLessons
@ComputerScienceLessons 2 жыл бұрын
It's hard to believe it was nearly 4 years ago. What a fool I was then! Thanks BTW. :)KD
@ryanalnaser914
@ryanalnaser914 2 жыл бұрын
thanks for anything or where I stop
@ToanPham-wr7xe
@ToanPham-wr7xe 8 ай бұрын
😮
@Gravityys
@Gravityys 4 жыл бұрын
Denary = Decimal for those who don't know
@Gravityys
@Gravityys 4 жыл бұрын
Great video btw,really helping me grasp the basics of cs and understand them.
@ComputerScienceLessons
@ComputerScienceLessons 4 жыл бұрын
Glad to be help :) KD
Binary 3 - Fixed Point Binary Fractions
6:46
Computer Science
Рет қаралды 57 М.
Twos complement: Negative numbers in binary
13:49
Ben Eater
Рет қаралды 1,2 МЛН
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 8 МЛН
Gym belt !! 😂😂  @kauermtt
00:10
Tibo InShape
Рет қаралды 15 МЛН
Binary Addition and Subtraction With Negative Numbers, 2's Complements & Signed Magnitude
24:57
Characters, Symbols and the Unicode Miracle - Computerphile
9:37
Computerphile
Рет қаралды 2 МЛН
Binary 1 - Converting to and from Denary
9:31
Computer Science
Рет қаралды 82 М.
You Can't Measure Time
17:33
Up and Atom
Рет қаралды 452 М.
Quest To Find The Largest Number
11:43
CodeParade
Рет қаралды 262 М.
Diffie-Hellman Key Exchange: How to Share a Secret
9:09
Spanning Tree
Рет қаралды 137 М.
1's complement and 2's complement | Signed Binary Numbers Explained
16:54
ALL ABOUT ELECTRONICS
Рет қаралды 201 М.
Binary and Two's Complement
9:15
Gary Explains
Рет қаралды 11 М.
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 8 МЛН