int
Prev | Orchestra Opcodes and Operators | Next

## int

int — Extracts an integer from a decimal number.

## Description

Returns the integer part of x.

## Syntax

    int(x)  (init-rate or control-rate; also works at audio rate in Csound5)

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.

## Examples

Here is an example of the int opcode. It uses the file int.csd.

Example 438. Example of the int opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac   ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o int.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    instr 1

    icount init 0
    loop:
      inum = icount / 3
      inm  = int(inum)
      prints "integer (%f/3) = %f\\n", icount, inm
    loop_lt icount, 1, 10, loop

    endin
    </CsInstruments>
    <CsScore>

    i 1 0 0
    e
    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like these:

    integer (0.000000/3) = 0.000000
    integer (1.000000/3) = 0.000000
    integer (2.000000/3) = 0.000000
    integer (3.000000/3) = 1.000000
    integer (4.000000/3) = 1.000000
    integer (5.000000/3) = 1.000000
    integer (6.000000/3) = 2.000000
    integer (7.000000/3) = 2.000000
    integer (8.000000/3) = 2.000000
    integer (9.000000/3) = 3.000000

## See Also

abs, exp, frac, log, log10, i, sqrt

## Credits

Prev | Up | Next
instr | Home | integ