Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 2261

csound-doc-5.19.01-10.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>&amp;</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="opbitshr.html" title="&gt;&gt;" />
    <link rel="next" href="opbitor.html" title="|" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">&amp;</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="opbitshr.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="opbitor.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="&amp;">
      <a id="opbitand"></a>
      <div class="titlepage"></div>
      <a id="IndexAmp" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">&amp;</span>
        </h2>
        <p>&amp; — 
      Bitwise AND operator.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp13114560"></a>
        <h2>Description</h2>
        <p>
      The bitwise operators perform operations of bitwise AND, bitwise
    OR, bitwise NOT and bitwise non-equivalence. 
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp13115288"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">a <span class="command"><strong>&amp;</strong></span> b  (bitwise AND)</pre>
        <p>
      where the arguments <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> may be further expressions.  They are
    converted to the nearest integer to machine precision and then the
    operation is performed.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp13110240"></a>
        <h2>Performance</h2>
        <p>
    The priority of these operators is less binding that the
    arithmetic ones, but more binding that the comparisons. 
    </p>
        <p>
      Parentheses may be used as above to force particular groupings.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp13111240"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the bitwise AND and OR operators. It uses the file <a class="ulink" href="examples/bitwise.csd" target="_top"><em class="citetitle">bitwise.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp13138536"></a>
          <p class="title">
            <strong>Example 33. Example of the bitwise operators.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>

<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="oblock">instr</span> 1
iresultOr <span class="op">=</span> p4 <span class="op">|</span> p5
iresultAnd <span class="op">=</span> p4 <span class="op">&amp;</span> p5
<span class="opc">prints</span> "<span class="op">%</span><span class="opc">i</span> <span class="op">|</span> <span class="op">%</span><span class="opc">i</span>  <span class="op">=</span> <span class="op">%</span>i\\n", p4, p5, iresultOr
<span class="opc">prints</span> "<span class="op">%</span><span class="opc">i</span> <span class="op">&amp;</span> <span class="op">%</span><span class="opc">i</span>  <span class="op">=</span> <span class="op">%</span>i\\n", p4, p5, iresultAnd
<span class="oblock">endin</span>


<span class="oblock">instr</span> 2 <span class="comment">; decimal to binary converter</span>
Sbinary <span class="op">=</span> ""
inumbits <span class="op">=</span> 8
icount <span class="opc">init</span> inumbits <span class="op">-</span> 1

<span class="olabel">pass</span><span class="op">:</span>

	ivalue <span class="op">=</span> 2 <span class="op">^</span> icount
	<span class="octrl">if</span> (p4 <span class="op">&amp;</span> ivalue <span class="op">&gt;=</span> ivalue) then
		Sdigit <span class="op">=</span> "1"
	<span class="octrl">else</span>
		Sdigit <span class="op">=</span> "0"
	<span class="octrl">endif</span>
	Sbinary <span class="opc">strcat</span> Sbinary, Sdigit

<span class="octrl">loop_ge</span> icount, 1, 0, <span class="olabel">pass</span>

Stext <span class="opc">sprintf</span> "<span class="op">%</span><span class="opc">i</span> is <span class="op">%</span>s <span class="opc">in</span> binary\\n", p4, Sbinary
<span class="opc">prints</span> Stext
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> 1 0 0.1  1  2
<span class="stamnt">i</span> 1 +  .   1  3
<span class="stamnt">i</span> 1 +  .   2  4
<span class="stamnt">i</span> 1 +  .   3  10

<span class="stamnt">i</span> 2 2 0.1   12
<span class="stamnt">i</span> 2 +  .    9
<span class="stamnt">i</span> 2 +  .    15
<span class="stamnt">i</span> 2 +  .    49

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp13140816"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="opbitor.html" title="|"><em class="citetitle">|</em></a>, 
      <a class="link" href="opnonequiv.html" title="#"><em class="citetitle">#</em></a>, 
      <a class="link" href="opbitnot.html" title="¬"><em class="citetitle">¬</em></a>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="opbitshr.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="opbitor.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">&gt;&gt; </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> |</td>
        </tr>
      </table>
    </div>
  </body>
</html>