• Tidak ada hasil yang ditemukan

Fundamentals of Programming

N/A
N/A
Protected

Academic year: 2024

Membagikan "Fundamentals of Programming"

Copied!
22
0
0

Teks penuh

(1)

Fundamentals of Programming

session 30

Bit Operations

(2)

Bitwise operations

● AND (&)

● OR (|)

● XOR (^)

● NOT (~)

(3)

Bitwise AND

x y x & y

0 0 0

0 1 0

1 0 0

1 1 1

(4)

Bitwise OR

x y x | y

0 0 0

0 1 1

1 0 1

1 1 1

(5)

Bitwise XOR

x y x ^ y

0 0 0

0 1 1

1 0 1

1 1 0

(6)

Bitwise NOT

x ~x

0 1

1 0

(7)

Bitwise Operations

x 01101101

y 10001110

x & y 00001100

x | y 11101111

x ^ y 11100011

~x 10010010

char x = 0x6D,y = 0x8E;

(8)

Shift operations

x 01101101

x << 1 11011010 x << 3 01101000

unsigned char x = 0x6D;

(9)

Shift operations

x 01101101

x << 1 11011010 x << 3 01101000

unsigned char x = 0x6D;

(10)

Shift operations

x 00000000 01101101 109

x << 1 00000000 11011010 218 x << 3 00000011 01101000 872

unsigned short int x = 0x6D;

(11)

Shift operations

x 11101101 237

x >> 1 01110110 118 = 237/2 x >> 3 00011101 29 = 237/8

unsigned char x = 0xED;

(12)

Shift operations

x 11101101 -19

x >> 1 11110110 -10 x >> 3 11111101 -3

y 01101101 109

y >> 1 00110110 54 y >> 3 00001101 13

signed char x = 0xED, y = 0x6D;

(13)

Shift operations

x &= y x = x & y

x |= y x = x | y

x ^= y x = x ^ y

x <<= y x = x << y x >>= y x = x >> y

(14)

Printing numbers in bits

(15)

Printing numbers in bits

(16)

Printing numbers in bits

(17)

Printing numbers in bits

(18)

Printing numbers in bits

(19)

Printing numbers in bits

(20)

https://www.tutorialspoint.com/cprogramming/c_operators_precedence.htm

mind precedence

if ( x & mask == 0 )

if ( (x & mask) == 0 )

(21)

Bit Fields

(22)

Bit Fields

Referensi

Dokumen terkait

From the analysis of The Google Adwords Fundamentals, the researcher can conclude that The Google Adwords Fundamentals uses grammatical cohesive devices in

Parametric Programming by Macro Parametric programming [10] is applied to CNC operations in generating a single CNC program for parts with similar design, inventing macros for

Journal of Management and Accounting Studies www.researchub.org Fundamentals of Criminalization of Tax Evasion in the Iranian Legal System Mohammad Ghasem Karimi Varaki1*, Mousa

117 Dictionary Operations 14 Complexity of dictionary operations implemented with a linked list for an n entry dictionary: • We can no longer use binary search to locate an item in

Keywords: Blended learning, e-learning, fundamentals of nursing course, Iran, nursing student Improving Nursing Students’ Learning Outcomes in Fundamentals of Nursing Course through

Use Logic programming to implement real deductive databases, show the completeness of the resolution procedure, apply Logic programming and implement efficiently in Logic Programming

The document contains the results of a quiz on the fundamentals of radio

Fundamentals of Coalbed Methane Reservoir Engineering by John Seidle