summaryrefslogtreecommitdiff
path: root/opcodes/adds.xml
blob: 84617bcba6b3352c6c9aeb353aca2bb375e74f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<refentry id="adds">
<indexterm id="IndexPlus"><primary>&plus;</primary></indexterm>
  <refentryinfo><title>Mathematical Operations:Arithmetic and Logic Operations</title></refentryinfo>
  <refmeta>
    <refentrytitle>&plus;</refentrytitle>
  </refmeta>


 
  <refnamediv>
    <refname>&plus;</refname>

    <refpurpose>
      Addition operator
          </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      Arithmetic operators perform operations of change-sign (negate), don't-change-sign, logical AND logical OR, add, subtract, multiply and divide. Note that a value or an expression may fall between two of these operators, either of which could take it as its left or right argument, as in
      <literallayout>
a + b * c.
      </literallayout>
    </para>

    <para>
      In such cases three rules apply:
    </para>

    <para>
      1. &ast; and <emphasis>&sol;</emphasis> bind to their neighbors more strongly than &plus; and &minus;. Thus the above expression is taken as
      <literallayout>  
a + (b * c)
      </literallayout>
      with &ast; taking b and c and then &plus; taking a and b &ast; c.
    </para>

    <para>
      2. <emphasis>&plus;</emphasis> and <emphasis>&minus;</emphasis> bind more strongly than &amp;&amp;, which in turn is stronger than &verbar;&verbar;:
      <literallayout>  
a &amp;&amp; b - c &verbar;&verbar; d
      </literallayout>
      is taken as
      <literallayout>  
(a &amp;&amp; (b - c)) &verbar;&verbar; d
      </literallayout>
    </para>

    <para>
      3. When both operators bind equally strongly, the operations are done left to right:
      <literallayout>  
a - b - c
      </literallayout>
      is taken as
      <literallayout>  
(a - b) - c
      </literallayout>
    </para>

    <para>
      Parentheses may be used as above to force particular groupings.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis><command>&plus;</command>a  (no rate restriction)</synopsis>
    <synopsis>a <command>&plus;</command> b  (no rate restriction)</synopsis>

    <para>
      where the arguments <emphasis>a</emphasis> and <emphasis>b</emphasis> may be further expressions.
    </para>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the &plus; operator. It uses the file <ulink url="examples/adds.csd"><citetitle>adds.csd</citetitle></ulink>.

      <example>
        <title>Example of the &plus; operator.</title>

        

        <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
          <xi:include href="examples-xml/adds.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>

      Its output should include lines like:
      <screen>
instr 1:  i1 = 32.000</screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="subtracts"><citetitle>-</citetitle></link>, 
      <link linkend="opand"><citetitle>&amp;&amp;</citetitle></link>, 
      <link linkend="opor"><citetitle>&verbar;&verbar;</citetitle></link>, 
      <link linkend="multiplies"><citetitle>&ast;</citetitle></link>, 
      <link linkend="divides"><citetitle>&sol;</citetitle></link>, 
      <link linkend="raises"><citetitle>&circ;</citetitle></link>, 
      <link linkend="modulus"><citetitle>&percnt;</citetitle></link>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>Example written by &namekevin;.</para>
  </refsect1>
</refentry>