bit()

Description

Calcule la valeur numérique d'un bit spécifié (bit 0 vaut 1, bit 1 vaut 2, bit 2 vaut 4, etc.).

Syntaxe


bit(n)

Paramètres

  • n: le rang du bit dont il faut calculer la valeur, en commençant à 0 pour le bit de poids faible (le plus à droite)

Valeurs Renvoyées

  • La valeur calculée du bit

Exemple


void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps long x; for (int n = 0; n < 16; n++) { x = bit(n); // equivalent to x = 1 << n; Serial.println(x, BIN); } } void loop() { }

The result in Serial Monitor:

COM6
Send
1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 100000000000 1000000000000 10000000000000 100000000000000 1000000000000000
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Voir Également

※ ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • Any suggestion, correction, and translation? please email us at ArduinoGetStarted@gmail.com, We appreciate it
  • We mainly keep improving the references in English. See English version of this page for the latest update.