-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.txt
30 lines (16 loc) · 1.44 KB
/
info.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Bit Shifting
If you multiply, then the operations will move/shift the numbers to the left
253 * 10 = 2530
418 * 1000 = 418000
If you divide, then the operations will move/shift the numbers to the right
458 / 10 = 048
820 / 1000 = 000
172 / 100 = 001
This applies to base 10 and of course base 2.
Really Useful in Game Development
-Arithmetic and Logical Bit Shifting: Binary Numbers can be represented in signed and unsigned way. Unsigned Binary Numbers do not have sign bit, whereas signed binary numbers uses signed bit as well or these can be distinguishable between positive and negative numbers. A signed binary is a specific data type of a signed variable. Example: 11010011 - this Binary Number means that is negative or signed. Example 2: 00110011 - This Binary Number means that is positive or unsigned.
If we have the binary number 10101100 and we use right bit shift operation >>, we are changing the value of the number to a positive or unsigned number and we call this logical shifting 01010011
When to use Bit Shifting:
-It completely depends on target device, language, purpose , etc. If we are implementing business solutions, we probably do not have to worry about these things.
-As a rule of thump, do not use it unless you are absolutely sure that there is a performance gain (Modern Compilers usually optimize this).
-Prefer Code Readability, Bit Shifting has an obscure syntax, and not everyone in your team understand what it does.