09.12.2012 Views

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Arithmetic Operations<br />

Besides the usual operations of addition, subtraction, multiplication, and division (+, -, *, and /), here are<br />

some of the arithmetic operators you can use in Smalltalk:<br />

// divide and truncate the result towards negative infinity<br />

\\ mod<br />

** raise to a power<br />

abs absolute value<br />

inverse 1 divided by receiver<br />

quo: divide and truncate the result towards zero<br />

rem: like mod except truncated towards zero<br />

rounded add 0.5 and truncate<br />

truncated round towards negative infinity<br />

vmax: take the maximum of receiver and argument<br />

vmin: take the minimum of receiver and argument<br />

For example,<br />

-7 // 3 -3<br />

7 // 3 2<br />

-7 \\ 3 2<br />

7 \\ 3 1<br />

2 inverse 1/2<br />

-7 quo: 3 -2<br />

7 quo: 3 2<br />

-7 rem: 3 -1<br />

7 rem: 3 1<br />

-2.5 rounded -2.0<br />

-2.5 truncated -3<br />

5 vmax: 2 5<br />

5 vmin: 2 2<br />

Mathematical Functions<br />

<strong>The</strong> following are some of the more common mathematical functions that are available in Smalltalk:<br />

ln natural log<br />

exp exponent<br />

sqrt square root<br />

sin sine<br />

cos cosine<br />

normCos (receiver * π) cos<br />

normSin (receiver * π) sin<br />

log log of receiver base 10<br />

twoLog log of receiver base 2<br />

twoExp two raised to the receiver<br />

<strong>The</strong> expression<br />

2 raisedTo: 10<br />

means two raised to the tenth power.<br />

516

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!