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::
67 an link::Classes/Integer::.
68 returns:: a random value from zero to this, excluding the value exclude.
72 an link::Classes/Integer::.
73 returns:: a random value from this.neg to this, excluding the value exclude.
75 subsection:: Conversion
78 returns:: a link::Classes/Char:: which has the ASCII value of the receiver.
81 returns:: a link::Classes/Char:: which represents the receiver as an ASCII digit.
82 discussion:: For example code::5.asDigit:: returns code::$5::.
84 method:: asBinaryDigits
85 returns:: an array with the binary digits (integer 0 or 1).
88 returns:: an array with the n-ary digits.
90 See also the complementary method link::Classes/SequenceableCollection#-convertDigits::.
96 method:: asBinaryString
97 returns:: a string with the binary digits (0 or 1).
100 returns:: a string with the hexadecimal digits (integer 0 to F).
103 returns:: a string in IP format.
106 Interpret this as index into a scale with a given number of steps per ocatve.
109 2.degreeToKey([0, 2, 5, 7, 11]);
113 Returns:: the gray code for the number.
119 subsection:: Binary Representation
122 set nth bit to zero (bool = false) or one (bool = true)
124 method::leadingZeroes
127 method:: trailingZeroes
131 returns:: number of required bits
134 subsection:: Properties
137 returns:: true if dividable by 2 with no rest
140 returns:: true if not dividable by 2 with no rest
143 subsection:: Powers Of Two
145 method:: nextPowerOfTwo
146 returns:: the next power of two greater than or equal to the receiver.
149 13.nextPowerOfTwo.postln;
150 64.nextPowerOfTwo.postln;
153 method:: isPowerOfTwo
154 returns:: the whether the receiver is a power of two.
157 13.isPowerOfTwo.postln;
158 64.isPowerOfTwo.postln;
162 subsection:: Prime Numbers
165 returns:: the nth prime number. The receiver must be from 0 to 6541.
168 [0,1,2,3,4,5].collect({ arg i; i.nthPrime; }).postln;
172 returns:: the next prime less than or equal to the receiver up to 65521.
179 returns:: the next prime less than or equal to the receiver up to 65521.
186 returns:: whether the receiver is prime.
193 method:: indexOfPrime
194 returns:: the index of a prime number less than or equal to the receiver up to 65521.
195 If the receiver is not a prime, the answer is nil.
206 returns:: a Boolean for whether or not the specified pid is running.
210 p.pidRunning; // cat will stay alive