Diferencia entre revisiones de «or»

De ArduWiki
Saltar a: navegación, buscar
(Referencias)
(Referencias externas)
 
(No se muestran 5 ediciones intermedias del mismo usuario)
Línea 16: Línea 16:
 
== Sintaxis ==
 
== Sintaxis ==
 
<pre>
 
<pre>
 +
espresion 1 or expresion 2
 
espresion 1 || expresion 2
 
espresion 1 || expresion 2
 
</pre>
 
</pre>
Línea 23: Línea 24:
  
 
== Advertencias ==
 
== Advertencias ==
* No confundir el operador boleano '''or''' <nowiki>||</nowiki>, con el operador [[or bit a bit]] <nowiki>|</nowiki>.
+
* No confundir el operador boleano '''or''' (<nowiki>||</nowiki>), con el operador [[or bit a bit]] (<nowiki>|</nowiki>).
  
 
== Ejemplo ==
 
== Ejemplo ==
 
<syntaxhighlight lang="c++">
 
<syntaxhighlight lang="c++">
if (x 9 || x 20){
+
if (x < 9 || x > 20){
 +
  //Esta fuera del rango
 +
}else{
 
   //Esta entre 10 y 19
 
   //Esta entre 10 y 19
}else{
 
  //Esta fuera del rango
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Vea también ==
 
== Vea también ==
* [[not]] <nowiki>(!)</nowiki>
+
<categorytree mode=all>Operador logico</categorytree>
* [[and]] <nowiki>(&&)</nowiki>
 
* [[xor]] <nowiki>(^)</nowiki>
 
* [[not bit a bit]] <nowiki>(~)</nowiki>
 
* [[and bit a bit]] <nowiki>(&)</nowiki>
 
* [[or bit a bit]] <nowiki>(|)</nowiki>
 
* [[xor bit a bit]] <nowiki>(^)</nowiki>
 
* [[bitshift right]] <nowiki>(>>)</nowiki>
 
* [[bitshift left]] <nowiki>(<<)</nowiki>
 
  
== 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://programarfacil.com/blog/programacion/la-logica-en-la-programacion/ La lógica en la programacion] - Luis Del Valle
 
* [https://programarfacil.com/blog/programacion/la-logica-en-la-programacion/ La lógica en la programacion] - Luis Del Valle
 +
* [https://aprendiendoarduino.wordpress.com/category/operadores/ Operadores] - Aprendiendo Arduino
  
 
[[Category:Operador logico]]
 
[[Category:Operador logico]]

Revisión actual del 17:39 6 jun 2020

Descripción

Es un operador boleano or || que permite unir dos expresiones lógicas de manera disyuntiva ("o"). Sus posibles resultados son dados por la siguiente tabla de verdad:

a b a || b
0 0 0
1 0 1
0 1 1
1 1 1

Sintaxis

espresion 1 or expresion 2
espresion 1 || expresion 2

Retorna

Verdadero o falso.

Advertencias

  • No confundir el operador boleano or (||), con el operador or bit a bit (|).

Ejemplo

if (x < 9 || x > 20){
   //Esta fuera del rango
}else{
   //Esta entre 10 y 19
}

Vea también

  and
  not
  or
  xor


Referencias externas