Diferencia entre revisiones de «not bit a bit»

De ArduWiki
Saltar a: navegación, buscar
(Referencias)
(Vea también)
 
(No se muestran 5 ediciones intermedias del mismo usuario)
Línea 34: Línea 34:
  
 
== Vea también ==
 
== Vea también ==
 +
Operatores logicos
 
* [[not]] <nowiki>(!)</nowiki>
 
* [[not]] <nowiki>(!)</nowiki>
 
* [[and]] <nowiki>(&&)</nowiki>
 
* [[and]] <nowiki>(&&)</nowiki>
 
* [[or]] <nowiki>(||)</nowiki>
 
* [[or]] <nowiki>(||)</nowiki>
 
* [[xor]] <nowiki>(^)</nowiki>
 
* [[xor]] <nowiki>(^)</nowiki>
 +
 +
Operadores bit a bit
 
* [[and bit a bit]] <nowiki>(&)</nowiki>
 
* [[and bit a bit]] <nowiki>(&)</nowiki>
 
* [[or bit a bit]] <nowiki>(|)</nowiki>
 
* [[or bit a bit]] <nowiki>(|)</nowiki>
 
* [[xor bit a bit]] <nowiki>(^)</nowiki>
 
* [[xor bit a bit]] <nowiki>(^)</nowiki>
 +
 +
<categorytree mode=all>Operador bit a bit</categorytree>
 +
<categorytree mode=all>Funciones bit y byte</categorytree>
  
 
== 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 actual del 19:36 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

Operatores logicos

Operadores bit a bit


Referencias externas