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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Numbers<br />

Integers, <strong>for</strong> example,<br />

7 -9<br />

are written as numerals with no decimal points.<br />

To express an integer in another radix, <strong>for</strong> example as a binary or hexadecimal number<br />

2r1010 16rEFFF<br />

type the base, followed by the letter r, followed by the number expressed in that radix. For example, a<br />

number expressed in base 2 is a binary number and contains only 1s and 0s. For radix numbers greater<br />

than 10, any numbers represented by letters can be in upper or lower case (e.g. 16rFFF or 16rfff).<br />

Sending the message printStringRadix: to a decimal integer will give a string that contains that<br />

number expressed in the given base. For example:<br />

17 printStringRadix: 2<br />

would evaluate to '10001', which is a string that contains the binary representation of 17.<br />

Floating point numbers are expressed as numerals with decimal points, <strong>for</strong> example,<br />

1.3 0.1611<br />

Floating point numbers can also be expressed in scientific notation (the following example expresses<br />

1.14 × 10 10 in scientific notation):<br />

1.14e10<br />

Like integers, a floating point number in another radix is preceded by the radix and an r, <strong>for</strong> example,<br />

2r10.1<br />

<strong>The</strong>re must be a numeral be<strong>for</strong>e the radix point, even if that number is a zero. For example, the number<br />

.5<br />

must be written as<br />

0.5<br />

or it will not be interpreted correctly. In Smalltalk, a period indicates the end of a sentence. A decimal<br />

point that is not preceded by a zero is ambiguous; it could be the period terminating a previous statement,<br />

rather than a decimal point. By always making the leading zero explicit, you remove this<br />

ambiguity.<br />

<strong>The</strong> number<br />

0.991 % 1<br />

is an example of a complex number in Smalltalk; the first number is the real part, and the second number<br />

is the imaginary part.<br />

515

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

Saved successfully!

Ooh no, something went wrong!