| 1 | |
| 2 | <refentry id="raises"> |
| 3 | <indexterm id="IndexCirc"><primary>ˆ</primary></indexterm> |
| 4 | <refentryinfo><title>Mathematical Operations:Arithmetic and Logic Operations</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>ˆ</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>ˆ</refname> |
| 11 | <refpurpose> |
| 12 | <quote>Power of</quote> operator. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | 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 |
| 20 | <literallayout> |
| 21 | a + b * c. |
| 22 | </literallayout> |
| 23 | </para> |
| 24 | |
| 25 | <para> |
| 26 | In such cases three rules apply: |
| 27 | </para> |
| 28 | |
| 29 | <para> |
| 30 | 1. * and <emphasis>/</emphasis> bind to their neighbors more strongly than + and −. Thus the above expression is taken as |
| 31 | <literallayout> |
| 32 | a + (b * c) |
| 33 | </literallayout> |
| 34 | with * taking b and c and then + taking a and b * c. |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | 2. <emphasis>+</emphasis> and <emphasis>−</emphasis> bind more strongly than &&, which in turn is stronger than ||: |
| 39 | <literallayout> |
| 40 | a && b - c || d |
| 41 | </literallayout> |
| 42 | is taken as |
| 43 | <literallayout> |
| 44 | (a && (b - c)) || d |
| 45 | </literallayout> |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | 3. When both operators bind equally strongly, the operations are done left to right: |
| 50 | <literallayout> |
| 51 | a - b - c |
| 52 | </literallayout> |
| 53 | is taken as |
| 54 | <literallayout> |
| 55 | (a - b) - c |
| 56 | </literallayout> |
| 57 | </para> |
| 58 | |
| 59 | <para> |
| 60 | Parentheses may be used as above to force particular groupings. |
| 61 | </para> |
| 62 | |
| 63 | <para> |
| 64 | The operator <emphasis>ˆ</emphasis> raises <emphasis>a</emphasis> to the <emphasis>b</emphasis> power. <emphasis>b</emphasis> may not be audio-rate. Use with caution as precedence may not work correctly. See <link linkend="pow"><citetitle>pow</citetitle></link>. (New in Csound version 3.493.) |
| 65 | </para> |
| 66 | </refsect1> |
| 67 | |
| 68 | <refsect1> |
| 69 | <title>Syntax</title> |
| 70 | <synopsis>a <command>ˆ</command> b (b not audio-rate)</synopsis> |
| 71 | |
| 72 | <para> |
| 73 | where the arguments <emphasis>a</emphasis> and <emphasis>b</emphasis> may be further expressions. |
| 74 | </para> |
| 75 | </refsect1> |
| 76 | |
| 77 | <refsect1> |
| 78 | <title>Examples</title> |
| 79 | <para> |
| 80 | Here is an example of the ˆ operator. It uses the file <ulink url="examples/raises.csd"><citetitle>raises.csd</citetitle></ulink>. |
| 81 | |
| 82 | <example> |
| 83 | <title>Example of the ˆ operator.</title> |
| 84 | |
| 85 | |
| 86 | |
| 87 | <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> |
| 88 | <xi:include href="examples-xml/raises.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 89 | </example> |
| 90 | |
| 91 | Its output should include lines like these: |
| 92 | <screen> |
| 93 | i1 0.50000 |
| 94 | i1 0.50021 |
| 95 | i1 0.50042 |
| 96 | ...... |
| 97 | i1 1327.49320 |
| 98 | i1 1327.74465</screen> |
| 99 | </para> |
| 100 | </refsect1> |
| 101 | |
| 102 | <refsect1> |
| 103 | <title>See also</title> |
| 104 | <para><link linkend="MathArtLogic"><citetitle>Arithmetic and Logic Operations</citetitle></link></para> |
| 105 | </refsect1> |
| 106 | |
| 107 | </refentry> |