Lecture 5/12: Sign Extension

  Рет қаралды 23,988

hhp3

hhp3

Күн бұрын

Пікірлер: 22
@v1ct0rx24
@v1ct0rx24 2 жыл бұрын
you're a wizard harry
@anondoggo
@anondoggo 4 жыл бұрын
Thank you prof. You are saving lives.
@Brlitzkreig
@Brlitzkreig 2 жыл бұрын
Yes, he really is!
@IulianOnofrei
@IulianOnofrei 8 жыл бұрын
How do you know to stop at the previous to the last "1"? Why isn't "100 0101" the shrinked value of "1111 1111 1111 1111 1111 1111 1100 0101"?
@marekrimal2371
@marekrimal2371 7 жыл бұрын
I think that is because of the byte size. It must contain 8 bits, not 7. If you write 100 0101 so that technically means 0100 0101.
@archidar1
@archidar1 7 жыл бұрын
Binary 1111 is equal to Decimal -1. This is an important thing to note, that in negative, you are counting up to 1111. Therefore, 110101 (53) has the exact same negative value as 1111 110101 (1013), because they are both the same distance away from 111111 (63) and 1111 111111 (1023) respectively. The first case (110101) is 10 values away from 111111, thus it is -11 The second case (1111 110101) is 10 values away from 1111 111111, thus it is -11 This carries on for however many values of 1 you place at the front. What you are counting isn't the binary number itself, what you are counting is how far away the binary number is from -1 (aka 1111 ... 1111). This is because everytime you extend the length of the binary 1s, while you are doubling its possible negative numerics, you are also adding that number back. Example: 1011 (Eleven) = -5 Because it is 4 digits away from 1111 (Fifteen) which would be -1 (COS 1111...1111 IS ALWAYS -1) Compare the above to what happens when we expand the front 1s: 1111 1011 (251) = -5 Because it is still 4 digits away from 1111 1111 (255) This is because while 1000 0000 (128) is now = -128, once we add in the buffer ones it becomes 1111 0000 (240), which is -16 because it is 15 values away from 1111 1111 (255) We now add the original number back in: 1111 1011 = -5. This shows that though the length increase of bits causes the initial negative to be larger (from 1000 being = -8 to 1000 0000 being -128) the buffer 1s cause the overall extension to cancel out its effect, so the original number will always be the same distance away from -1, with or without the initial ones. Since the distance between the number and -1 is what we are concerned with for negative numbers, the buffer doesn't matter.
@regisjosefazoulay5854
@regisjosefazoulay5854 4 жыл бұрын
10:10 "a char is a bits" => mispelling, it's a "byte" (8 bits) right ?
@kitty_kee
@kitty_kee 4 жыл бұрын
No! He said "A char is 8 bits".
@regisjosefazoulay5854
@regisjosefazoulay5854 4 жыл бұрын
@@kitty_kee ah ok maybe a misuderstanding of the english accent....thx
@spirridd
@spirridd 7 жыл бұрын
24:38 "both of these are converted to signed numbers" Why not to unsigned?
@marekrimal2371
@marekrimal2371 7 жыл бұрын
How do I know whether it is sign extended or just a really big negative number? How do I distinguish these two numbers after the extension (to 4 bytes for example): 1101 1010 1111 1111 1101 1010
@archidar1
@archidar1 7 жыл бұрын
Binary 1111 is equal to Decimal -1. This is an important thing to note, that in negative, you are counting up to 1111. Therefore, 110101 (53) has the exact same negative value as 1111 110101 (1013), because they are both the same distance away from 111111 (63) and 1111 111111 (1023) respectively. The first case (110101) is 10 values away from 111111, thus it is -11 The second case (1111 110101) is 10 values away from 1111 111111, thus it is -11 This carries on for however many values of 1 you place at the front. What you are counting isn't the binary number itself, what you are counting is how far away the binary number is from -1 (aka 1111 ... 1111). This is because everytime you extend the length of the binary 1s, while you are doubling its possible negative numerics, you are also adding that number back. Example: 1011 (Eleven) = -5 Because it is 4 digits away from 1111 (Fifteen) which would be -1 (COS 1111...1111 IS ALWAYS -1) Compare the above to what happens when we expand the front 1s: 1111 1011 (251) = -5 Because it is still 4 digits away from 1111 1111 (255) This is because while 1000 0000 (128) is now = -128, once we add in the buffer ones it becomes 1111 0000 (240), which is -16 because it is 15 values away from 1111 1111 (255) We now add the original number back in: 1111 1011 = -5. This shows that though the length increase of bits causes the initial negative to be larger (from 1000 being = -8 to 1000 0000 being -128) the buffer 1s cause the overall extension to cancel out its effect, so the original number will always be the same distance away from -1, with or without the initial ones. Since the distance between the number and -1 is what we are concerned with for negative numbers, the buffer doesn't matter.
@anondoggo
@anondoggo 4 жыл бұрын
@@archidar1 Thank you! I had the same question and this is so helpful!
@jasonmiller6424
@jasonmiller6424 6 жыл бұрын
5:35 why is 8-F negative and 0-7 positive in hex?
@ginicholas4322
@ginicholas4322 6 жыл бұрын
change it to binary and you'll see
@MattyMatiss
@MattyMatiss 8 жыл бұрын
I did't know that the insignificant part in negative numbers is filled with 1s and Fs. Thank you for the lesson
@Folsets
@Folsets 5 жыл бұрын
Hi! How the computer knows whether an integer is signed or unsigned?
@kitty_kee
@kitty_kee 4 жыл бұрын
Basically you have to tell computer. Integer is signed by default so if you have to declare unsigned number or you want to typecast then you have to use *unsigned* keywords. Hope you will be satisfy by my answer.
@goldfish8196
@goldfish8196 8 жыл бұрын
THANK YOU.
@飴旨
@飴旨 3 жыл бұрын
去去武器走
@sharathchandra6349
@sharathchandra6349 4 жыл бұрын
Tw
@asdsa7434
@asdsa7434 5 жыл бұрын
You sound like Trump
Lecture 4/12: Signed and Unsigned Numbers
18:02
hhp3
Рет қаралды 18 М.
Twos complement: Negative numbers in binary
13:49
Ben Eater
Рет қаралды 1,2 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Python's decimals SOLVE the floating point problem!
17:00
Carberra
Рет қаралды 2,9 М.
Lecture 3/65: Finite State Machines: Examples
29:33
hhp3
Рет қаралды 54 М.
Shifting and Sign Extension (15)
14:14
Course Academy
Рет қаралды 4,9 М.
Lecture 3/12: Bits, Bytes and Words
15:07
hhp3
Рет қаралды 150 М.
Lecture 6/12: Arithmetic Operations
26:34
hhp3
Рет қаралды 6 М.
Marty Lobdell - Study Less Study Smart
59:56
Pierce College District WA
Рет қаралды 24 МЛН
Faster than Rust and C++: the PERFECT hash table
33:52
strager
Рет қаралды 613 М.
Binary Addition and Subtraction With Negative Numbers, 2's Complements & Signed Magnitude
24:57
Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF
28:34
Decomplexify
Рет қаралды 2,2 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН