Diferencia entre revisiones de «not bit a bit»

De ArduWiki
Saltar a: navegación, buscar
(Vea también)
(Vea también)
 
(No se muestran 9 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
 
== Descripción ==
 
== Descripción ==
El operador binario bit a bit NOT es representado por el caracter tilde ~. NOT 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.
+
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.
  
 
{| class="wikitable col2cen"
 
{| class="wikitable col2cen"
Línea 12: Línea 12:
 
== Sintaxis ==
 
== Sintaxis ==
 
<pre>
 
<pre>
~var
+
~variable;
 
</pre>
 
</pre>
;var: una variable (de cualquier tipo).
+
 
 +
== Parametros ==
 +
;variable: una variable tipo numerica.
  
 
== Retorno ==
 
== Retorno ==
Línea 32: Línea 34:
  
 
== Vea también ==
 
== Vea también ==
* [[not]]
+
Operatores logicos
* [[and]]
+
* [[not]] <nowiki>(!)</nowiki>
* [[or]]
+
* [[and]] <nowiki>(&&)</nowiki>
* [[and bit a bit]]
+
* [[or]] <nowiki>(||)</nowiki>
* [[or bit a bit]]
+
* [[xor]] <nowiki>(^)</nowiki>
 +
 
 +
Operadores bit a bit
 +
* [[and bit a bit]] <nowiki>(&)</nowiki>
 +
* [[or 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 ==
+
== 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:Estructura]]
+
[[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