First Spin Episode 017 - Unary Operators
Автор: tymkrs
Загружено: 2020-02-12
Просмотров: 8
Описание:
This week on First Spin we remind everyone about the Parallax Expo (woohoo!) and then start on Unary Operators! Addie gets a bit confused by the subtle difference between pre and post increments/decrements - but our resident experts are patient and explain wonderfully! We also hash out sign-extensions!
We go through:
: Add
: Subtract
-X : Pre-decrement
X- - : Post-decrement
++X : Pre-increment
X++ : Post-increment
^^ : Square root
|| : Absolute Value
~ / ~~ : Sign Extension
(--) Example discussed:
a := X- - + 10 X = 2
a := X + 10 and X = X - 1
a := 2 + 10 and X = 2 - 1
a := 12 X = 1
VERSUS
a := - -X + 10 X = 2
a := (X-1) + 10 and X = 2-1
a := 1 + 10 and X = 1
a := 11 X = 1
(++) Example discussed:
a := X++ + 10 X = 2
a := 12 X = 3
VERSUS
a:= ++X + 10 X=2
a := 13 X = 3
Sign Extension Discussion:
If you set dira/ina to ~ this sets all bits in a 32 long to 0 (though 32 depends on the context).
For example, Outa[4..5]~ will only set bits 4 and 5 to 0
~~ = -1 so if you set dira/ina to ~~, this turns all of the bits ON in a 32 bit long
With 1, the first bit of the 32 bit is ON. With -1, all bits are ON.
If you put it (~ or ~~) in front of a variable (X) it sign-extends. So if you have a 8-bit value, positive or negative, then you use sign extension to sign extend it into a full 32 bit value.
So if you had just a BYTE (0-7) as a variable (vs WORD (8-16) or LONGs(17-32)). This lets you take a variable from a BYTE or WORD and ensures that the signed value (positive or negative) of the number is properly copied over to a LONG.
Toymaker Television, Zombie Tech, First Spin, Tymkrs Minecraft World Tour
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: