# bit testing problem in mikroC for AVR

Status
Not open for further replies.

#### Noman Yousaf

##### Full Member level 4
hi all
i am using mikro C for AVR.
how can i test or edit a bit in a variable int?like i have an 8 bit int "reg" and i want to make bit5 of "reg",hi. or i want to check the bit 5 is hi or low, for both cases, what i have to do? help please.

#### andre_luis

##### Super Moderator
Staff member
how can i test or edit a bit in a variable ?

Test bit 5:
Code:
if ( reg & 0b00100000 ) { //stuff here }
Edit bit 5:
Code:
reg |= 0b00100000 // Set bit
reg &= 0b11011111 // Clear bit

Noman Yousaf

Points: 2