Bitwise AND operator in c

Preview:

DESCRIPTION

Bit wise operators is one of the strength of a few programming languages like C, which gives facility to programmer to interact directly with H/W.

Citation preview

C AND operators .

1. logical AND (&&)

2. bit wise AND (&)

Decision control structure if condition logical && .

if( percentage >= 60 && percentage < 70)

{

printf("First Class with distinction\n");

}

printf statement control if conditions true

.

bit wise AND (&) . फ expression व व

bits व . Bit wise operation returns 1 when both of its operands are 1. ग bit

wise & operator truth table...?

Table 1 Table 2

. Interesting . conclusion

1. 0 (Zero) AND result 0 (Zero)

2. 1 AND result original .

points bit operations .

ए . words bit wise AND

0 1 1 0 1 0 1 1 1 0 0 0 0 1 0 1

&

0 1 1 0 1 0 1 1 1 0 0 0 0 1 0 1

0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 1

Resultant Bit Pattern

operator . Bit wise operators

.

ए values . flag

information ए bit 8 bits ए byte reserve .

arithmetic operations bit wise operations .

Bit wise AND masking .

ए .

32 bits graphics 2 words information . In 32 bit dWord there are 4

distinct values.

Low byte is for Blue (0 to 7)

The next significant byte is value for Green (8 to 15)

Then a byte for Red (16 to 23)

High byte is for Transparency (24 to 31)

color dWord

AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB

32 bit dWord integer Red color extract ? ए

bits zero (0) Red byte . bit wise &

(AND) operator . So we will be having one variable mask

o (Zero) erase .

mask ...?

0000 0000 1111 1111 0000 0000 0000 0000

direct C code . hexadecimal conversion

Hex post . hex code 0X00FF0000

.

dWord mask bit wise AND

AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB

&

0000 0000 1111 1111 0000 0000 0000 0000

--------------------------------------------------------------------------------

0000 0000 1111 1111 0000 0000 0000 0000

Red color bits 0 (Zero) AND

erase . . ए

Bit wise Shift operator example

carry over .

Happy Coding...!

Recommended