User Tools

Site Tools


notes:discrete:fall2023:projects:ttb1

This is an old revision of the document!


TTB1

BITWISE LOGIC

BITWISE AND

Bitwise AND uses the “&” symbol. It checks if the two inputs are numbers and if so then it gives back a 1.

For example if we have an int set to 12 and an int set to 6 if we preform a bitwise & operation on them the result would be a 0100. 12 in binary is 1100 and 6 in binary is 0110.

12 6 6&12
1 0 0
1 1 1
0 1 0
0 0 0

In this example of bitwise & gives us the result as 4. You can test this out yourself in code.

    int num1 = 12;    // Binary: 1100
    int num2 = 6;     // Binary: 0110
    int result = num1 & num2;  // Perform bitwise AND operation
 
    printf("num1: %d\n", num1);
    printf("num2: %d\n", num2);
    printf("result: %d\n", result);

it prints out the result as follows:

num1: 12
num2: 6
result: 4

BITWISE OR

Bitwise OR uses the “|” symbol. It checks if the either of the two inputs are not zero and gives a 1.

12 6 6 or 12
1 0 1
1 1 1
0 1 1
0 0 0

In this example the result of 12 or 6 is 14.

BITWISE XOR

Bitwise XOR uses the “^” symbol. Returns 1 only if the 2 bits are different.

12 6 6 or 12
1 0 1
1 1 0
0 1 1
0 0 0

BITWISE NOT

Bitwise NOT uses the “~” symbol. It inverts all the bits in a single number.

12 ~12
1 0
1 0
0 1
0 1

POTENTIAL FEATURES

LARGER PADDLE

PADDLE MAGNET

BRICK HIT POINTS

INVINCIBLE BALL

notes/discrete/fall2023/projects/ttb1.1695167386.txt.gz · Last modified: 2023/09/19 23:49 by jwieland