2 summary:: Integer number
6 A 32 bit integer. Integer inherits most of its behaviour from its superclass.
10 subsection:: Iteration
13 Executes strong::function:: for all integers from zero to this minus one.
15 a link::Classes/Function:: which is passed two arguments, both of which are the same
16 integer from zero to this minus one. The reason two arguments are passed is for
17 symmetry with the implementations of do in link::Classes/Collection::.
20 Executes strong::function:: for all integers from this minus one to zero.
23 Executes strong::function:: for all integers from this to strong::endval::, inclusive.
25 an link::Classes/Integer::.
27 a link::Classes/Function:: which is passed two arguments, the first which is an integer from this to
28 endval, and the second which is a number from zero to the number of iterations minus one.
31 Executes strong::function:: for all integers from this to strong::endval::, inclusive, stepping each time by strong::stepval::.
33 an link::Classes/Integer::.
35 an link::Classes/Integer::.
37 a link::Classes/Function:: which is passed two arguments, the first which is an integer from this to
38 endval, and the second which is a number from zero to the number of iterations minus one.
41 Returns:: an link::Classes/Array:: of this size filled by objects generated from evaluating the strong::function::.
44 Returns:: a link::Classes/Collection:: of strong::class:: of this size filled by objects generated from evaluating the strong::function::.
47 returns:: an link::Classes/Interval:: from this to strong::hi::.
50 returns:: an array with a geometric series of this size from start.
53 returns:: an array with a fibonacci series of this size beginning with strong::a:: and strong::b::.
56 returns:: the prime factors as array.
59 returns:: the factorial of this.
62 subsection:: Random Numbers
63 See also: link::Guides/Randomness::
66 returns:: a random value from zero to this, excluding the value exclude.
68 an link::Classes/Integer::.
71 returns:: a random value from this.neg to this, excluding the value exclude.
73 an link::Classes/Integer::.
76 subsection:: Conversion
79 returns:: a link::Classes/Char:: which has the ASCII value of the receiver.
82 returns:: a link::Classes/Char:: which represents the receiver as an ASCII digit.
83 discussion:: For example code::5.asDigit:: returns code::$5::.
85 method:: asBinaryDigits
86 returns:: an array with the binary digits (integer 0 or 1).
89 returns:: an array with the n-ary digits.
91 See also the complementary method link::Classes/SequenceableCollection#-convertDigits::.
97 method:: asBinaryString
98 returns:: a string with the binary digits (0 or 1).
101 returns:: a string with the hexadecimal digits (integer 0 to F).
104 returns:: a string in IP format.
107 Interpret this as index into a scale with a given number of steps per ocatve.
110 2.degreeToKey([0, 2, 5, 7, 11]);
114 Returns:: the gray code for the number.
120 subsection:: Binary Representation
123 set nth bit to zero (bool = false) or one (bool = true)
125 method::leadingZeroes
128 method:: trailingZeroes
132 returns:: number of required bits
135 subsection:: Properties
138 returns:: true if dividable by 2 with no rest
141 returns:: true if not dividable by 2 with no rest
144 subsection:: Powers Of Two
146 method:: nextPowerOfTwo
147 returns:: the next power of two greater than or equal to the receiver.
150 13.nextPowerOfTwo.postln;
151 64.nextPowerOfTwo.postln;
154 method:: isPowerOfTwo
155 returns:: the whether the receiver is a power of two.
158 13.isPowerOfTwo.postln;
159 64.isPowerOfTwo.postln;
163 subsection:: Prime Numbers
166 returns:: the nth prime number. The receiver must be from 0 to 6541.
169 [0,1,2,3,4,5].collect({ arg i; i.nthPrime; }).postln;
173 returns:: the next prime less than or equal to the receiver up to 65521.
180 returns:: the next prime less than or equal to the receiver up to 65521.
187 returns:: whether the receiver is prime.
194 method:: indexOfPrime
195 returns:: the index of a prime number less than or equal to the receiver up to 65521.
196 If the receiver is not a prime, the answer is nil.
207 returns:: a Boolean for whether or not the specified pid is running.
211 p.pidRunning; // cat will stay alive
217 Returns:: the bits from the Macintosh GetKeys() Toolbox call. Receiver should be 0 to 3.
220 [0.getKeys, 1.getKeys, 2.getKeys, 3.getKeys].postln;