WEBVTT

00:00.400 --> 00:01.240
Hello, everyone.

00:01.880 --> 00:02.640
I'm typhoon.

00:02.920 --> 00:10.600
Welcome to today's comprehensive lecture on binary subtraction and handling signed integers using two's

00:10.640 --> 00:11.440
complement.

00:12.080 --> 00:17.800
We will explore important concepts clearly and interactively to help you deeply understand how computers

00:17.800 --> 00:20.800
perform arithmetic with signed numbers.

00:21.520 --> 00:27.160
In binary arithmetic, numbers can be positive or negative.

00:27.840 --> 00:34.480
To represent this in binary, we typically use one bit, known as the sign bit.

00:35.160 --> 00:38.760
This is the sign bit in assigned integers.

00:38.760 --> 00:41.560
In unsigned integers, we don't have a sign bit.

00:41.600 --> 00:46.440
Since we don't have a sign bit, we have more values to store.

00:47.120 --> 00:55.000
But the drawback is in unsigned integers we don't have a negative numbers, so the sign bit indicates

00:55.000 --> 00:58.440
whether a number is positive or negative.

00:59.080 --> 01:05.740
Initially, you might consider simply just that this zero.

01:06.260 --> 01:11.260
If you have zero in assigned integers as a first bit, it is.

01:11.300 --> 01:11.660
What?

01:11.700 --> 01:12.740
Positive, right?

01:13.140 --> 01:16.900
But here if we have one, it means it is negative.

01:17.580 --> 01:24.820
However, this straightforward method known as sign magnitude leads to problems when adding numbers.

01:25.420 --> 01:28.340
Now let's look at a simple example here.

01:28.740 --> 01:31.980
So we have what zero one.

01:32.020 --> 01:34.780
Or let's use another color for this.

01:35.540 --> 01:42.060
We have 0010 which is what.

01:42.740 --> 01:43.580
Positive two.

01:44.140 --> 01:48.460
And 1010.

01:48.500 --> 01:49.300
Which is what.

01:49.700 --> 01:50.580
Negative two.

01:51.100 --> 01:55.540
And if you calculate that what we will get one one.

01:56.260 --> 02:03.240
The result is 1100 which represents what Minus four instead of two.

02:03.480 --> 02:05.400
But the real result should be.

02:05.440 --> 02:05.760
What?

02:05.800 --> 02:06.200
Two.

02:06.840 --> 02:07.280
Zero.

02:07.760 --> 02:12.320
Now, clearly a different method is needed here to overcome this problem.

02:13.080 --> 02:17.400
Most computers use two complement notation.

02:17.440 --> 02:22.480
Before we dive deeper, let's clearly understand complement concepts in mathematics.

02:22.720 --> 02:30.360
Now we have the complement of number a number you add to another to reach a specific base or whole.

02:31.120 --> 02:34.840
Example is the complement of 37.

02:34.880 --> 02:39.840
In base ten which is decimal with two digits are 63.

02:39.960 --> 02:47.640
Because what 37 plus 63 is 100, right?

02:48.280 --> 02:51.920
This is complement and the two's complement in binary.

02:52.600 --> 02:59.200
Now for binary numbers two's complement is simple way to represent negative numbers allowing easy addition

02:59.200 --> 03:00.760
and subtraction operations.

03:00.760 --> 03:02.460
Us now here.

03:02.860 --> 03:08.140
Let's look at how two's complement notation works practically in binary arithmetic.

03:08.820 --> 03:13.460
Here you see plus one is 0000010.

03:13.660 --> 03:19.180
And minus one is 1111110.

03:19.300 --> 03:24.700
So it works like in reverse basically.

03:25.100 --> 03:34.220
So key observations about two's complement is the first bit is often called the sign bit with what zero

03:34.220 --> 03:36.820
for positive and one for negative.

03:37.500 --> 03:43.620
This notation allows arithmetic operations without special instructions and the range from a four bit

03:43.660 --> 03:45.660
integer integer.

03:45.820 --> 03:48.740
So what we have here is four bits, right?

03:49.460 --> 03:57.340
The range for the four bit integer is what is from minus eight to plus seven.

03:58.060 --> 04:04.350
In the unsigned it can from 0 to 16 or 15 or 16, right?

04:05.030 --> 04:07.750
That's how it basically works.

04:08.470 --> 04:09.910
You get negative numbers.

04:10.110 --> 04:15.390
But the drawback is you will get twice less.

04:16.630 --> 04:23.750
Now let's revisit our previous example on adding plus two and minus two.

04:24.550 --> 04:26.270
This time using two's complement.

04:26.550 --> 04:30.550
So we will use again 0010.

04:30.550 --> 04:36.950
And the two is remember 11101110.

04:37.750 --> 04:42.550
And what we will get here is 0000.

04:42.990 --> 04:46.230
The result is zero correctly represents zero.

04:47.070 --> 04:49.830
Demonstrating the advantage of two's complement notation.

04:49.990 --> 04:56.910
Clearly here you can see zero is always 000 doesn't matter in an inside or outside right.

04:57.430 --> 05:03.530
To ensure you understand these concepts well here's a quick exercise using four bits four bit two's

05:03.530 --> 05:09.170
complement at minus three and plus three for the binary result.

05:09.170 --> 05:13.490
Clearly and explain yourself briefly on your own notepad.

05:13.890 --> 05:14.570
Pause the video.

05:14.570 --> 05:23.810
Now try to exercise yourself and resume the solution to see the solution here.

05:24.570 --> 05:35.130
The solution is but 1101 and 1100.

05:35.890 --> 05:44.850
This is minus three plus 311 goes as zero again 000.

05:45.170 --> 05:52.010
The binary result correctly represents zero, confirming our understanding of two's complement addition.

05:52.010 --> 05:53.570
So use complement.

05:54.170 --> 06:00.490
Now two's complement is extensively used in modern computing for arithmetic operations due to its efficiency.

06:00.530 --> 06:06.550
Now this simplicity in arithmetic circuits make it the standard across nearly all computing devices,

06:06.550 --> 06:08.830
from smartphones to supercomputers.

06:09.070 --> 06:15.710
Understanding these two's complement helps you grasp more complex computing principles clearly.

06:15.990 --> 06:22.950
And in today's lecture, we have covered why simple sine magnitude methods aren't practical for arithmetic.

06:23.590 --> 06:30.550
You see, when we try to use the minus one plus two, we got the wrong result here, right?

06:31.510 --> 06:35.950
And we also learned the importance and utility of two's complement notation.

06:36.230 --> 06:42.910
We also learned the practical examples and interactive exercises for adding and subtracting sine integers

06:42.910 --> 06:44.190
using two's complement.

06:44.790 --> 06:50.990
Now by mastering these concepts, you will well be prepared for advanced topics in computer organizations

06:51.390 --> 06:54.150
and computing or low level computing.

06:54.830 --> 06:56.630
Thanks for joining today's lecture.

06:56.630 --> 07:02.710
Feel free to ask any questions and I look forward to seeing you in our next lecture.
