title | categories | subCategories | ||
---|---|---|---|---|
bit() |
|
|
Prints the output of bit(n)
for n=0 to n=10 to the serial monitor. Values returned are 1 2 4 8 16 till 1024.
void setup() {
Serial.begin(9600);
}
void loop() {
for(int n=0;n<=10;n++) //loop from n=0 till 10
{
Serial.print(" "); //space between numbers, for readability
Serial.print(bit(n)); //print the value of bit(n)
delay(1000);
}
}
The variable n
must be an integer type. float and double will return an error and the program will not compile.
The maximum value that can be returned by bit(n)
is 2^31 = 2147483648 after which 0 is returned.