Diferencia entre revisiones de «not bit a bit»

De ArduWiki
Saltar a: navegación, buscar
(Vea también)
(Referencias externas)
Línea 46: Línea 46:
 
== Referencias externas ==
 
== Referencias externas ==
 
* [https://www.arduino.cc/reference/es/language/functions/time/millis/ Guia de referencia de Arduino]
 
* [https://www.arduino.cc/reference/es/language/functions/time/millis/ Guia de referencia de Arduino]
 +
* [https://playground.arduino.cc/Code/BitMath/#bitwise_not Bitwise NOT] - Playgorund
  
 
[[Category:Operador bit a bit]]
 
[[Category:Operador bit a bit]]

Revisión del 19:30 26 sep 2019

Descripción

El operador not bit a bit es representado por el caracter tilde ~. Opera sobre el numero a su derecha cambiando cada bit a su valor opuesto, es decir: cada 0 se convierte en 1 y 1 se convierte en 0.

a ~a
0 1
1 0

Sintaxis

~variable;

Parametros

variable
una variable tipo numerica.

Retorno

El valor de dicha variable, pero con todos sus bits invertidos.

Advertencias

  • No confundir el operador bit a bit not con el boleano not !

Ejemplo

byte a = B11110000;
byte b = ~a;  //B00001111
int a = 103; //B0000000001100111 = 103
int b = ~ a; //B1111111110011000 = -104
x = ~ x; // alternar todos los bits en x y almacenar de nuevo en x

Vea también


Referencias externas