Skip to content

Commit a942f0a

Browse files
authored
Merge pull request #750 from AshutoshPandey123456/patch-2
Added Example Code/ Notes and warnings to bitClear() reference
2 parents 682851d + 6fc04ce commit a942f0a

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

Diff for: Language/Functions/Bits and Bytes/bitClear.adoc

+34-1
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,45 @@ Clears (writes a 0 to) a bit of a numeric variable.
3434

3535
[float]
3636
=== Returns
37-
Nothing
37+
`x`: the value of the numeric variable after the bit at position `n` is cleared.
3838

3939
--
4040
// OVERVIEW SECTION ENDS
4141

4242

43+
44+
// HOW TO USE SECTION STARTS
45+
[#howtouse]
46+
--
47+
48+
[float]
49+
=== Example Code
50+
// Describe what the example code is all about and add relevant code
51+
Prints the output of `bitClear(x,n)` on two given integers. The binary representation of 6 is 0110, so when `n=1`, the second bit from the right is set to 0. After this we are left with 0100 in binary, so 4 is returned.
52+
53+
[source,arduino]
54+
----
55+
void setup() {
56+
Serial.begin(9600);
57+
while (!Serial) {
58+
; // wait for serial port to connect. Needed for native USB port only
59+
}
60+
61+
int x = 6;
62+
int n = 1;
63+
Serial.print(bitClear(x, n)); // print the output of bitClear(x,n)
64+
}
65+
66+
void loop() {
67+
}
68+
----
69+
[%hardbreaks]
70+
71+
--
72+
// HOW TO USE SECTION ENDS
73+
74+
75+
4376
// SEE ALSO SECTION
4477
[#see_also]
4578
--

0 commit comments

Comments
 (0)