| 1 | |
| 2 | <refentry id="int"> |
| 3 | <indexterm id="IndexInt"><primary>int</primary></indexterm> |
| 4 | <refentryinfo><title>Mathematical Operations:Mathematical Functions</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>int</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>int</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Extracts an integer from a decimal number. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Returns the integer part of <emphasis>x</emphasis>. |
| 23 | </para> |
| 24 | </refsect1> |
| 25 | |
| 26 | <refsect1> |
| 27 | <title>Syntax</title> |
| 28 | <synopsis><command>int</command>(x) (init-rate or control-rate; also works at audio rate in Csound5)</synopsis> |
| 29 | |
| 30 | <para> |
| 31 | where the argument within the parentheses may be an expression. Value converters perform arithmetic translation from units of one kind to units of another. The result can then be a term in a further expression. |
| 32 | </para> |
| 33 | </refsect1> |
| 34 | |
| 35 | <refsect1> |
| 36 | <title>Examples</title> |
| 37 | <para> |
| 38 | Here is an example of the int opcode. It uses the file <ulink url="examples/int.csd"><citetitle>int.csd</citetitle></ulink>. |
| 39 | |
| 40 | <example> |
| 41 | <title>Example of the int opcode.</title> |
| 42 | <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> |
| 43 | <xi:include href="examples-xml/int.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 44 | </example> |
| 45 | Its output should include lines like these: |
| 46 | <screen> |
| 47 | integer (0.000000/3) = 0.000000 |
| 48 | integer (1.000000/3) = 0.000000 |
| 49 | integer (2.000000/3) = 0.000000 |
| 50 | integer (3.000000/3) = 1.000000 |
| 51 | integer (4.000000/3) = 1.000000 |
| 52 | integer (5.000000/3) = 1.000000 |
| 53 | integer (6.000000/3) = 2.000000 |
| 54 | integer (7.000000/3) = 2.000000 |
| 55 | integer (8.000000/3) = 2.000000 |
| 56 | integer (9.000000/3) = 3.000000 |
| 57 | </screen> |
| 58 | Here is an example for the rounding-group, comparing the different rounding opcodes. It uses the file <ulink url="examples/rounding-group.csd"><citetitle>rounding-group.csd</citetitle></ulink>. |
| 59 | <example> |
| 60 | <title>Example of the rounding group.</title> |
| 61 | <xi:include href="examples-xml/rounding-group.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 62 | </example> |
| 63 | </para> |
| 64 | </refsect1> |
| 65 | |
| 66 | <refsect1> |
| 67 | <title>See also</title> |
| 68 | <para><link linkend="MathMatfunc"><citetitle>Mathematical Functions</citetitle></link></para> |
| 69 | </refsect1> |
| 70 | |
| 71 | <refsect1> |
| 72 | <title>Credits</title> |
| 73 | </refsect1> |
| 74 | </refentry> |