bitClear()
Description
Clears (writes a 0 to) a bit of a numeric variable.
Syntax
bitClear(x, n)
Parameter Values
- x: the numeric variable whose bit to clear.
- n: which bit to clear, starting at 0 for the least-significant (rightmost) bit.
Return Values
- x: the value of the numeric variable after the bit at position n is cleared.
Example Code
Demonstrates the use of bitClear() by printing the value of a variable to the Serial Monitor before and after the use of bitClear().
void setup() {
Serial.begin(9600);
byte x = 0b10000100; // the 0b prefix indicates a binary constant
Serial.print("BEFORE: ");
Serial.println(x, BIN); // 10000100
bitClear(x, 2); // clear the third bit
Serial.print("AFTER: ");
Serial.println(x, BIN); // 10000000
}
void loop() {}
The result in Serial Monitor:
COM6
BEFORE: 10000100
AFTER: 10000000
Autoscroll
Clear output
9600 baud
Newline
See Also
- Language : bit()
- Language : bitRead()
- Language : bitSet()
- Language : bitWrite()
- Language : highByte()
- Language : lowByte()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.