<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wx="http://ilps.science.uva.nl/WikiXML/wx" xml:lang="pt" lang="pt">
<head>
<title>Lógica binária</title>
<meta name="wx_namespace" content="0"/>
<meta name="wx_pagename" content="Lógica_binária"/>
<meta name="wx_page_id" content="51101"/>
</head>
<body>
<div id="wx_article">
<wx:section level="1" title="Lógica binária" id="wxsec1"><h1 class="pagetitle" id="wx1">Lógica binária</h1>

<p id="wx2">A <b id="wx3">lógica binária</b>, ou <i id="wx4">bitwise operation</i> é a base de todo o cálculo computacional. Na verdade, são estas operações mais básicas que constituem todo o poderio dos <a href="/wpt/Computador" title="Computador" wx:linktype="known" wx:pagename="Computador" wx:page_id="536" id="wx5">computadores</a>. Qualquer operação, por mais complexa que pareça, é traduzida internamente pelo <a href="/wpt/Processador" title="Processador" wx:linktype="known" wx:pagename="Processador" wx:page_id="1492" id="wx6">processador</a> para estas operações.</p>

<p id="wx7">Operações</p>

<div id="wx_toc"/>

<a id="NOT" name="NOT"/>
<wx:section level="3" title="NOT" id="wxsec3"><h3 id="wx8">NOT</h3>

<p id="wx9">O operador unário NOT, ou <b id="wx10"><a href="/wpt/Nega%C3%A7%C3%A3o" title="Negação" wx:linktype="known" wx:pagename="Negação" wx:page_id="419698" id="wx11">negação</a> binária</b> resulta no complemento do operando, i.e., será um <a href="/wpt/Bit" title="Bit" wx:linktype="known" wx:pagename="Bit" wx:page_id="12372" id="wx12">bit</a> '1' se o operando for '0', e será '0' caso contrário, conforme podemos confirmar pela tabela de verdade, onde A é o bit de entrada e S é o bit-resposta, ou bit de saida:</p>

<pre id="wx13">
   |  A  |  S  |
 --+-----+-----+
   |  0  |  1  |
 --+-----+-----+
   |  1  |  0  |
 --+-----+-----+
</pre>

<a id="AND" name="AND"/>
</wx:section><wx:section level="3" title="AND" id="wxsec4"><h3 id="wx14">AND</h3>

<p id="wx15">O operador binário AND, ou <b id="wx16"><a href="/wpt/Conjun%C3%A7%C3%A3o_l%C3%B3gica" title="Conjunção lógica" wx:linktype="known" wx:pagename="Conjunção_lógica" wx:page_id="782" id="wx17">conjunção</a> binária</b> devolve um <a href="/wpt/Bit" title="Bit" wx:linktype="known" wx:pagename="Bit" wx:page_id="12372" id="wx18">bit</a> 1 sempre que <b id="wx19">ambos</b> operandos sejam '1', conforme podemos confirmar pela tabela de verdade, onde A e B são bits de entrada e S é o bit-resposta, ou bit de saida:</p>

<pre id="wx20">
 B |  A  |  S  |
 --+-----+-----+
 0 |  0  |  0  |
 --+-----+-----+
 0 |  1  |  0  |
 --+-----+-----+
 1 |  0  |  0  |
 --+-----+-----+
 1 |  1  |  1  |
 --+-----+-----+
</pre>

<a id="OR" name="OR"/>
</wx:section><wx:section level="3" title="OR" id="wxsec5"><h3 id="wx21">OR</h3>

<p id="wx22">O operador binário OR, ou <b id="wx23"><a href="/wpt/Disjun%C3%A7%C3%A3o_l%C3%B3gica" title="Disjunção lógica" wx:linktype="known" wx:pagename="Disjunção_lógica" wx:page_id="24527" id="wx24">disjunção</a> binária</b> devolve um <a href="/wpt/Bit" title="Bit" wx:linktype="known" wx:pagename="Bit" wx:page_id="12372" id="wx25">bit</a> 1 sempre que <b id="wx26">pelo menos um</b> dos operandos seja '1', conforme podemos confirmar pela tabela de verdade, onde A e B são os bits de entrada e S é o bit-resposta, ou bit de saida:</p>

<pre id="wx27">
 B |  A  |  S  |
 --+-----+-----+
 0 |  0  |  0  |
 --+-----+-----+
 0 |  1  |  1  |
 --+-----+-----+
 1 |  0  |  1  |
 --+-----+-----+
 1 |  1  |  1  |
 --+-----+-----+
</pre>

<a id="XOR" name="XOR"/>
</wx:section><wx:section level="3" title="XOR" id="wxsec6"><h3 id="wx28">XOR</h3>

<p id="wx29">O operador binário <a href="/wpt/XOR" title="XOR" wx:linktype="known" wx:pagename="XOR" wx:page_id="1071165" id="wx30">XOR</a>, ou <b id="wx31"><a href="/wpt/Disjun%C3%A7%C3%A3o_l%C3%B3gica" title="Disjunção lógica" wx:linktype="known" wx:pagename="Disjunção_lógica" wx:page_id="24527" id="wx32">disjunção</a> binária exclusiva</b> devolve um <a href="/wpt/Bit" title="Bit" wx:linktype="known" wx:pagename="Bit" wx:page_id="12372" id="wx33">bit</a> 1 sempre que <b id="wx34">apenas um</b> dos operandos é '1', conforme podemos confirmar pela tabela de verdade:</p>

<pre id="wx35">
 B |  A  |  S  |
 --+-----+-----+
 0 |  0  |  0  |
 --+-----+-----+
 1 |  0  |  1  |
 --+-----+-----+
 0 |  1  |  1  |
 --+-----+-----+
 1 |  1  |  0  |
 --+-----+-----+
</pre>

<a id="Shift" name="Shift"/>
</wx:section><wx:section level="3" title="Shift" id="wxsec7"><h3 id="wx36"><i id="wx37">Shift</i></h3>

<p id="wx38">O operador unário de <i id="wx39"><a href="/wpt/Bit" title="Bit" wx:linktype="known" wx:pagename="Bit" wx:page_id="12372" id="wx40">bit</a> shifting</i>, ou <b id="wx41">deslocamento bit-a-bit</b>, equivale à multiplicação ou divisão por 2 do operando que, ao contrário dos casos anteriores, é um grupo de bits, e consiste no deslocamento para a esquerda ou para a direita do grupo de bits. O bit inserido é sempre 0, e o bit eliminado pode ser opcionalmente utilizado (flag CF dos registos do <a href="/wpt/Processador" title="Processador" wx:linktype="known" wx:pagename="Processador" wx:page_id="1492" id="wx42">processador</a>).</p>

<pre id="wx43">
 ( 101011(43) &gt;&gt; 1 ) =    010101[1]  
 ( 101011(43) &lt;&lt; 1 ) = [1]010110     
</pre>

<a id="Ver_tamb.C3.A9m" name="Ver_tamb.C3.A9m"/>
<wx:section level="2" title="Ver também" id="wxsec2"><h2 id="wx44">Ver também</h2>

<ul id="wx45">
<li id="wx46"><a href="/wpt/%C3%81lgebra_booleana" title="Álgebra booleana" wx:linktype="known" wx:pagename="Álgebra_booleana" wx:page_id="1978" id="wx47">Álgebra booleana</a></li>
</ul>
</wx:section></wx:section></wx:section></div>
<div id="wx_categorylinks">
<a href="/wpt/index.php?title=Especial:Categories&amp;article=L%C3%B3gica_bin%C3%A1ria" title="Especial:Categories" wx:linktype="known" wx:pagename="Especial:Categories" id="wx48">Categorias de páginas</a>: <span dir="ltr" id="wx49"><a href="/wpt/Categoria:L%C3%B3gica" title="Categoria:Lógica" wx:linktype="known" wx:pagename="Categoria:Lógica" wx:page_id="22410" id="wx50">Lógica</a></span></div>
<div id="wx_languagelinks">
Outras línguas: <a href="http://cs.wikipedia.org/wiki/Bitov%C3%BD_oper%C3%A1tor" class="external" wx:linktype="interwiki" wx:pagename="cs:Bitový_operátor" id="wx51">Česky</a> | <a href="http://de.wikipedia.org/wiki/Bitweiser_Operator" class="external" wx:linktype="interwiki" wx:pagename="de:Bitweiser_Operator" id="wx52">Deutsch</a> | <a href="http://en.wikipedia.org/wiki/Bitwise_operation" class="external" wx:linktype="interwiki" wx:pagename="en:Bitwise_operation" id="wx53">English</a> | <a href="http://eo.wikipedia.org/wiki/La%C5%ADbita_logiko" class="external" wx:linktype="interwiki" wx:pagename="eo:Laŭbita_logiko" id="wx54">Esperanto</a> | <a href="http://ja.wikipedia.org/wiki/%E3%83%93%E3%83%83%E3%83%88%E6%BC%94%E7%AE%97" class="external" wx:linktype="interwiki" wx:pagename="ja:ビット演算" id="wx55">日本語</a> | <a href="http://ko.wikipedia.org/wiki/%EB%B9%84%ED%8A%B8_%EC%97%B0%EC%82%B0" class="external" wx:linktype="interwiki" wx:pagename="ko:비트_연산" id="wx56">한국어</a> | <a href="http://ru.wikipedia.org/wiki/%D0%91%D0%B8%D1%82%D0%BE%D0%B2%D1%8B%D0%B5_%D0%BE%D0%BF%D0%B5%D1%80%D0%B0%D1%86%D0%B8%D0%B8" class="external" wx:linktype="interwiki" wx:pagename="ru:Битовые_операции" id="wx57">Русский</a> | <a href="http://vi.wikipedia.org/wiki/Ph%C3%A9p_to%C3%A1n_thao_t%C3%A1c_bit" class="external" wx:linktype="interwiki" wx:pagename="vi:Phép_toán_thao_tác_bit" id="wx58">Tiếng Việt</a></div>
</body>
</html>
