#### Federico Guzmán · July 25, 2015 at 2:28 pm

Prof. Brailsford is amazing, thanks for the video!

#### [email protected] · July 26, 2015 at 8:54 am

THIS IS THE LATEST STRATEGY.
YOU WILL BE FINANCIALLY FREE IF YOU LEARN THIS.
JUST WATCH THE VIDEO AND SEE………..https://youtu.be/-wnkYX8UQ5g

#### ScoopexUs · July 31, 2015 at 11:50 pm

Learning about how computers store numbers is very good 🙂 Just wanted to say it was a bit misleading to bring up undetectable "Not a Number" cases and then describe what is really the carry bit present in all CPUs since the 1970s. I.e. detectable and used a lot in all kinds of software 🙂

I think one important notion is to not get too used to 0 being positive just because it's stored as such in a computer. Oh, you can use it that way eminently in computers and it will turn out right. It's just that it could make you blush for math work. 0 is signless and has no unit. Moving on… have fun coding 🙂

#### amihart · August 8, 2015 at 7:08 am

I don't get why we sign bytes in the first place. What is stopping you from building a machine with no negative numbers? And once you do, can't you just implement negative numbers using software?

#### Teo St · August 9, 2015 at 10:44 am

Could someone tell me what would be the most significant bit of the number 1 0100 if the first bit shows the sign ? Thank you!

#### Neil Roy · September 20, 2015 at 7:50 pm

Thanks for this. I had a vague understanding of this, but I was never quite clear on it. This really cleared this up for me.

#### Abdelrahman Gamal · October 6, 2015 at 10:28 pm

Why's nobody explain why the math comes out right ?! It's because when you flip the bits and add one, you're actually adding 10000.. which has an additional digit more than the original numbers. It's like A-B = A+(C-B) ignoring the additional digit of the result which comes out to be C itself!

#### Ken White · October 12, 2015 at 4:20 am

Oppa Gangnam Style? Didn't youtube have to update their software because of this?

#### Alexander Bollbach · October 26, 2015 at 7:52 pm

this was a 'bit' confusing. i'll re-watch it, that should help.

#### Noel Goetowski · December 8, 2015 at 8:23 pm

What happened to Dr. B's finger?

#### Noel Goetowski · December 8, 2015 at 8:27 pm

9:43 Did anyone else immediately think of the Beach Boys right here?

#### Daniel Hale · December 9, 2015 at 10:07 pm

Watching these videos makes me absurdly giddy. I love learning (and re-learning, in case I've forgotten since college) how this stuff all works at the lowest levels. I wish I had more time to watch them throughout the day, but compiling breaks don't take as long as they used to. 😀

#### T33K3SS3LCH3N · December 28, 2015 at 4:35 pm

Easiest method of reading negative numbers in two's complement:
Seperate the leftmost digit from the rest, for example 1011 becomes 1000 (= 8) and 0011 (= 3). Take the negative of the left number and add it to the rest – in this case you get -8+5 = -3.

To understand how two's complement really works, Imagine the four-bit binary numbers as a circle. You start with 0000 at 12 o'clock, 1000 is at 6 o'clock, and the last number before you complete the circle and go back to 0 (between 11 and 12 o'clock) is 1111.
In unsigned binary this is where the overflow happens: 1111+1 (= 15+1) should be 10000 (= 16), but because you don't have that fifth bit you get 0 (0000) instead.

Now, this is how you read the same circle in two's complement: At 12 o'clock you have 0000 (= 0). To the right you increase the numbers (0001 = 1, 0010 = 2, 0011 = 3, …). This works until you arrive just short before 6 o'clock, where you have 0111 (=7), which is the highest positive number. So far the two's complement circle is just like it would be for unsigned binary.

But as we arrive at 6 o'clock where 1000 stands, we have a problem, because 1000 now is -8.
So as we add 0111 (=7) and 1, we get -8 instead of +8. This is where two's complement has its overflow.

Instead now go back to the 0000 and this time go down the circle to the left side: The first number you see there is 1111, and that is -1. Then you have 1110, and that is -2. So by going from the top down the left side, you count down from 0, until you arrive at 12 o'clock again to find 1000 = -8.

#### Harry Tsang · January 2, 2016 at 7:38 pm

so the 2038 problem can't be solve but replace with 64 bit

#### Billy Heng · January 27, 2016 at 6:31 am

Good lesson on binary flaw thanks how about address mode is there any issue and I notice there are problem in Unicode as well if you could have a lesson on those and is there any history on it. Happy to know thankyou very much.

#### Billy Heng · January 27, 2016 at 6:34 am

may be international timezone problem on 2000yrs bug issue usage of timestamp international worldwide on atomic clock spectrum timing and international human language in different continent. No, this world is full of problem and bugs all around PC.

#### Allan Richardson · January 29, 2016 at 5:55 pm

In the pre-360 world, the IBM 700/7000 series used sign and magnitude for their 36-bit binary integer arithmetic, adding the extra hardware to account for signs and overflows properly. Some programming languages, such as FORTRAN, used -0 to represent a word to which no value has yet been assigned; their compiled instructions tested for -0 before performing an operation, and knew that a programming error had occurred (using an uninitialized variable) if -0 was found. No arithmetic operation would ever GENERATE a -0 result; it could only appear as a result of copying a constant into it, or compiling an object program with that value (octal 400000000000, or in the hex notation devised later for the 360 series, 800000000) loaded into all variables with no initial value specified by the programmer.

Strangely, although integer math in the later 360 (introduced in 1965) used twos complement notation, FLOATING point math used sign-plus-true magnitude for the mantissa (significant digits) and an excess-64 notation of powers of 16 for the exponent (order of magnitude): in a 32-big (single precision) floating point number, the first bit was the sign (1 for negative) of the entire number, the next 7 bits represented the power of 16 plus 64 (0000000 meant 16^(-64), 1000000 meant 16^0, and 1111111 meant 16^63), and the remaining 24 bits represented a binary fraction. Double precision (64 bits) and extended precision (128 bits) kept the sign and magnitude the same and added the extra 32 (thus a total of 56) or 96 (for a total of 120) bits to the mantissa.

I suspect the reasons were that (a) floating point required more complex logic anyway, so temporarily generating twos complement for addition and subtraction were not much extra effort, (b) adding precision only required appending zero bits to the right, not the current value of the sign bit, and (c) more multiplying and dividing than adding and subtracting are done in the areas where floating point is commonly used, and those operations ignore the signs until the end, then determine the sign of the result from the signs of the operands.

1' มั่วมาหนี่น่า

#### Narin Pornwatcharakul · February 1, 2016 at 2:00 pm

1's ,2's มั่วมา แล้วตรงนี่หน่า

#### Alexandr Sevrjukov · February 14, 2016 at 8:30 am

I wish these videos were around back in the days when I was at college….

#### squirrel brains · April 23, 2016 at 3:25 pm

very good video. the small printout is rather out of focus most of the time though, while the handwritten is much clearer.

Thanks

#### snetsjs · May 10, 2016 at 7:07 pm

Excuse me if this is an ignorant question. Why not use a bit from a different memory address to hold the sign? It seems you could use (with 8 bit bytes) a single byte to hold the sign bit for 8 different numbers. My guess is the difference in resource usage and computing time makes this inefficient but I'm just curious about your explanation.

#### Amanda Dean · May 14, 2016 at 8:45 am

Ha
Haha
Hahaha
Hahahahahahahahahahahahahahhahahahahahahha

beautiful video

#### Anton Nym · September 12, 2016 at 4:00 am

This is beyond brilliant. Makes it so much easier when designing little ripple adders and such for ALUs! I especially appreciated the discussion of the rule for overflow. That would have taken me a while to work out. Wonderfully explained. Thank you!

#### TallWaters · September 24, 2016 at 3:30 pm

I want to know the black magic reason why adding one makes it all work out?

#### PacketCyclotron · October 27, 2016 at 7:53 pm

I really like Prof Brailsford.

#### PNWMan · October 31, 2016 at 2:15 am

I thought I was an "expert" on this kind of stuff, until I learned about the overflow rule at the end. This kinda gets me excited again about circuitry; very well explained 😀

amazing!

this is great!

#### Rex Galilae · February 27, 2017 at 2:45 pm

This man's charm distracts me from paying attention to what he says 😅

#### ferna2294 · March 6, 2017 at 7:48 am

I want my alarm clock to wake me up by the sound of 9:08

BTW for some reason I felt a big relief after he explained how to get rid of that negative zero.

#### Andrew White · March 6, 2017 at 9:07 pm

This was useful when computer ALU s could only add. Now the smallest of microcontroller can subtract in hardware. Most can multiply.
If it's large numbers that need manipulation, that's what C compilers do best.

#### leivadaros · May 25, 2017 at 10:58 pm

11:20 Almost overflowed there :p

#### Cooper Gates · June 5, 2017 at 11:13 pm

Ones' complement: "We have to check for +0 and -0"

No you don't. Just test if all the bits are the same. The XOR across the board would be 0.

#### Mister Voldemort · June 8, 2017 at 10:46 am

A level students here?

#### JamesBeanMachine · June 12, 2017 at 11:04 pm

My favourite thing ever is when integer overflow happens in a video game, and 2 billion points of healing becomes 2 billion points of damage, or vice versa.

#### Beep Doop · June 17, 2017 at 8:21 pm

its kind of obvious
we know through ordinary binary addition that:
1111+0001=_0000 =>
0000-0001=1111

0-1 = -1 = 15

all there is to it is that 0 and 16 is the same number
so 5 is both 0+5 and 16-11

-11=5 and -5=11

#### Carl T. · June 22, 2017 at 9:43 pm

Why have negative numbers in the first place?

#### Mohammed Boukhlouf · July 16, 2017 at 9:25 pm

Would it be possible to have English subtitles or auto generated subtitles?

#### lisamariefan · July 31, 2017 at 6:43 am

The "getting rid of the two zeroes" problem is getting into modular mathematics territory…

#### ProCactus · August 12, 2017 at 1:21 pm

Where does 'two' come into it ?

#### Dan J · August 18, 2017 at 10:45 am

I like how happy he got when +0 and -0 mapped to the same binary representation. It's almost like he won the lottery.

#### BATTLEMODE · October 16, 2017 at 10:07 pm

Great lecture, thank you!

#### Omar · October 22, 2017 at 3:10 pm

I like how he pictures the computer hardware having human emotions

#### Chibuike Abana · October 30, 2017 at 3:29 pm

i am working on a project that involves integer security. i noticed there is high chances of integer overflow which could be a serious issue. sharer insights with me please, on how this could lead to integer overflow

#### Megadardery · November 7, 2017 at 5:24 pm

The hardware overflow indication was brilliant.

#### bruh moment · November 10, 2017 at 10:14 pm

Wouldn't the altimeter go from 32767 to -32768?
A 16 bit signed integer is the smallest number of bits you can use with a sign and still get up to 30000, and it's got a maximum value of 32767
Not claiming the video is wrong, or even that it really matters, but I'm curious if you guys know something that I don't.

#### galier2 · November 19, 2017 at 10:08 am

Funny his example with the plane at the beginning as something similar happenned to the Mars Lander when it crashed. It thought it was several hundreds meter below surface and dropped its chute because of that, unfortunately it was still thousand of meter above surface.

#### galier2 · November 19, 2017 at 11:22 am

After reading some comments here, I have to rant here a little bit:

It's complEment with an E not compliment. A compliment is when someone says something nice about you. So I don't compliment you for your spelling :-).

#### Mr.Tweezy007 · November 30, 2017 at 11:44 am

These videos don't realy help tbh. The constant zooming in and out and focuss going off is silly and disorienting. I couldn't tell if this was supposed to be some sort of tutorial or an interview. Weak content.

#### Billy Heng · January 8, 2018 at 7:36 am

Why ? old computer power supply and slot has negative -5v & -12v not being use. Reverse bias idiode fundamental was not design for negative usage can that be done ????

#### madnc · January 14, 2018 at 6:57 pm

Anyone know how to represent -32 in 2's complement using 6 bits?

#### Mark Jacobs · January 15, 2018 at 5:06 pm

FINALLY!!! I now understand what overflow means. Thank you!!!

#### Eric von Wald · January 17, 2018 at 2:59 am

I would like to "compliment" you on an excellent presentation

#### jaime sterling · January 18, 2018 at 1:50 pm

this was bare confusing still ngl

#### viraltaco · January 27, 2018 at 10:11 pm

I'm glad someone solved this before I came around. Thank you mysterious person!

#### dasten123 · February 25, 2018 at 10:03 pm

I found it a bit hard to follow. Had to watch the beginning and the ending twice

#### Hrnek Bezucha · March 27, 2018 at 8:44 am

The ending was a bit confusing but what happens is that you have two bits somewhere in a register that signifies flags. Sign for positive or negative and overflow for out-of-range. These flags are set in hardware automagically whenever the count moves over a specific number in one way or the other.
In Arm the place it happens is xPSR – program status register.

#### Mishkafofer · April 29, 2018 at 6:10 pm

love camera work, live action.

#### Rev. Dave Moorman · May 2, 2018 at 9:15 pm

The famous 6502 doesn't do anything except addition. If you SBC (subtract with carry), you must Set the Carry before the action. The chip (evidently) does a EOR 255 on the subtrahend. You set the Carry, which is the +1 of 2's Compliment. Brilliant!

thank you sir!

#### Cigmorfil · May 7, 2018 at 11:12 am

There was an overflow bug in Micropose's Railroad Tycoon – if you bought more than 50% of the shares in your company (so you couldn't be thrown out) and then ran the railway in the most inefficient, loss making way possible, your cash would decrease through the negatives (overdrawn balance) until it overflowed and you ended up with the largest amount of positive cash; IIRC making money at this stage did not overflow back negative

#### Dark Thoughts but things are looking up · May 13, 2018 at 9:22 pm

In the PDP8 the instruction that did this was a bit sinister. It was known as Compliment and Increment the Accumulator CIA 😩

#### pcuser80 · May 18, 2018 at 6:11 pm

Does January 19, 2038 03:14:08 GMT rings a bell?

#### crayzk · May 21, 2018 at 9:39 pm

9:08 Yipee! Great video!

#### Mic k · May 28, 2018 at 10:47 pm

Ohhh reminds me of collage

#### vargonian · May 30, 2018 at 3:33 am

I don't understand how you could ever "carry a 0" out of the adder. Carrying a 1 makes sense, but you don't carry 0's… right?

#### MaggieRoara · July 25, 2018 at 11:13 am

Professor Brailsford, you splendid man! Thank you thank you thank you. Now I wish he explained how these get turned into hardware.

#### Jerry Kilpatrick · August 23, 2018 at 9:29 pm

I love this guy… I could watch his videos all day long.

#### jagardina · September 1, 2018 at 2:14 am

The devil is in the details. I really am impressed with how much thought has been put into computer science.

🙌🏻 🙌🏻 🙌🏻

#### praveen padala · September 20, 2018 at 1:04 am

how 1000 equals to -8 in twos complement when it is -0 in ones complement?

#### praveen padala · September 21, 2018 at 4:41 am

can you suggest textbook to study the two's complement in detail

#### Joel Dorrington · September 26, 2018 at 6:09 pm

Love this guy, he's cool and he loves what he does!

#### Balram Pillai · October 5, 2018 at 6:39 am

@9:10 Yipee. That was the best explanation to one's and two's ever

#### Stephen Liseo · October 11, 2018 at 3:40 am

You Sir are a gentleman and a scholar, great video

#### The Oracle of Awesomeness · November 9, 2018 at 5:42 pm

1:38 Positive and negative represented in binary,

#### Steve Alino · November 23, 2018 at 6:25 pm

So how is the sign number written in binary so the computer can tell it's a sign number and not an actual number please? For example how do you tell the difference between 10101001 meaning 169 or minus 41?

#### Sal Morreale · December 3, 2018 at 2:31 pm

I want to learn computer science from Professor Brailsford.

#### Gold Winger · December 20, 2018 at 7:53 pm

One of the machines I worked on as a young man frequently gave us negative zeros. So you couldn't use IF X.EQ.0 with any degree of confidence. I'm not sure which machine it was, it could have been the CDC 6400 or the CDC 7600.

#### Man Afro · December 21, 2018 at 8:56 pm

why is this guy making such weird faces all the time? it looks like he's in pain.

#### Jm56Z · March 13, 2019 at 9:46 am

An overflow is what happened to the first Ariane V rocket. It was driven by the same code as Ariane IV, but its acceleration was so great it overflowed, leading to the most sharp turn ever tried by a rocket.

#### Tyler Barnes · April 10, 2019 at 4:31 am

More down at the metal content like this !!!! <3

Yeepee😁😁

#### GH1618 · April 22, 2019 at 4:21 pm

About a third of my computer career was spent working with one’s complement machines. They worked well. The extra zero was not a big deal. The hardware took care of it.

#### Bhavuk Garg · April 26, 2019 at 6:24 am

Clear explanation, Finally I am clear about 2's complement. Thank you sir. I wish I have a teacher like you.

#### Steve Jones · May 6, 2019 at 10:10 am

I don't like thinking of a negative number in 2s complement just being a 's complement then adding one. To me, it's much more elegant to think of it as winding back from zero. That is, subtracting the number from zero, which to a human being at least, is just as easy as that adding 1 trick, but much more intuitive. However, the addition trick is no doubt easier in hardware, but from a human intuition point of view, the winding back of a the odometer from 0 provides a much more intuitive and, I think, accurate model.

The issue of detecting overflows (alluded to at the start and mentioned at the end) needs a whole area on its own. One of my big issues with implementation of C (and, maybe, other languages) is all those silent overflows that happen. Not just on a simple case of adding two positive integers and getting a negative without and exception, but the horrible things that happen with expressions combining different integer representations, both by length and whether signed or not. Silent overflows can happen when, unbeknown to the programmer, expressions are calculated within the expression using the "wrong" type of integer (signed or by length) for the output.

I once ported a C programme written and tested on a 32 bit machine, and it failed catastrophically on a 16 bit environment. That wasn't because care hadn't been taken to use longs and ints appropriately for the output, but because an int had been used within and expression and the the compiler produced code that worked with "int" precision, even though all other variables, including the output was long. No problem on the 16 bit environment, but it blew up on the 8 bit, but silently with no exceptions and splattered all over memory wiping out all the evidence of where it had gone wrong.

#### Jeremy Firth · June 11, 2019 at 1:34 pm

Nice camera/focus work on the close-ups on the paper. That was seamless and some high-end professional work.

#### Custard Tart · August 29, 2019 at 11:52 am

Dreadful camerawork distracting from the great message. Random zooming, annoyingly narrow depth of field when looking at anything apart from the presenter. Shame.

#### Michael Carr · September 27, 2019 at 6:09 pm

There's a Tower of Hanoi in the background. 👍👍👍

#### Jannis Adamek · October 11, 2019 at 1:35 pm

I love this video! the professor's explanation skills are extraordinary!

11111111 is -1

#### usuallydead · November 21, 2019 at 4:36 am

I feel like I just listened to Winnie the Pooh speak to me in binary for 16 mins.

#### Efe U · November 23, 2019 at 6:48 am

Thanks for the complete explanation.

#### RyuDarragh · December 24, 2019 at 7:33 pm

I design CPU hardware and did my ALU to treat "-0" as an indicator of an overflow. The O flag. The carry is still set, but the ALU outputs the O flag and promotes the high order bit for the S flag only if the O flag was not set, It functions as described in the video, but works regardless of the width, 8, 16 and 32 bits.

#### Udai Kumar · January 14, 2020 at 1:20 pm

Thanks professor for explaining the complements. I always wondered why we did like that . ☺️☺️☺️. As Elon Musk says , we should firstly tell the kids what is the actual purpose of a method itself before telling the method. Our brain recognizes that as important if we know it's actual use on real life.