Integer:
Filter:
Classes | Math

Integer : SimpleNumber : Number : Magnitude : Object

Integer number
Source: Integer.sc

Description

A 32 bit integer. Integer inherits most of its behaviour from its superclass.

NOTE: A 32 bit signed integer can represent values in the range -2147483648 to 2147483647. Adding up further returns in a wrapped result, so that and 2147483647+1= -2147483648. For a larger range, one can use Float, which is 64 bit and supports many (but not all) numerical methods that int does.

Class Methods

Inherited class methods

Instance Methods

Iteration

.do(function)

Executes function for all integers from zero to this minus one.

Arguments:

function

a Function which is passed two arguments, both of which are the same integer from zero to this minus one. The reason two arguments are passed is for symmetry with the implementations of do in Collection.

.reverseDo(function)

Executes function for all integers from this minus one to zero.

.for(endval, function)

Executes function for all integers from this to endval, inclusive.

Arguments:

endval

an Integer.

function

a Function which is passed two arguments, the first which is an integer from this to endval, and the second which is a number from zero to the number of iterations minus one.

.forBy(endval, stepval, function)

Executes function for all integers from this to endval, inclusive, stepping each time by stepval.

Arguments:

endval

an Integer.

stepval

an Integer.

function

a Function which is passed two arguments, the first which is an integer from this to endval, and the second which is a number from zero to the number of iterations minus one.

.collect(function)

Returns:

an Array of this size filled by objects generated from evaluating the function.

.collectAs(function, class)

Returns:

a Collection of class of this size filled by objects generated from evaluating the function.

.to(hi, step: 1)

Returns:

an Interval from this to hi.

.geom(start, grow)

Returns:

an array with a geometric series of this size from start.

.fib(a: 0.0, b: 1.0)

Returns:

an array with a fibonacci series of this size beginning with a and b.

.factors

Returns:

the prime factors as array.

Random Numbers

See also: Randomness

.xrand(exclude: 0)

Arguments:

exclude

an Integer.

Returns:

a random value from zero to this, excluding the value exclude.

.xrand2(exclude: 0)

Arguments:

exclude

an Integer.

Returns:

a random value from this.neg to this, excluding the value exclude.

Conversion

.asAscii

Returns:

a Char which has the ASCII value of the receiver.

.asDigit

Returns:

a Char which represents the receiver as an ASCII digit.

Discussion:

For example 5.asDigit returns $5.

.asBinaryDigits(numDigits: 8)

Returns:

an array with the binary digits (integer 0 or 1).

.asDigits(base: 10, numDigits)

Returns:

an array with the n-ary digits.

Discussion:

See also the complementary method SequenceableCollection: -convertDigits.

.asBinaryString(width: 8)

Returns:

a string with the binary digits (0 or 1).

.asHexString(width: 8)

Returns:

a string with the hexadecimal digits (integer 0 to F).

.asIPString

Returns:

a string in IP format.

.degreeToKey(scale, stepsPerOctave: 12)

Interpret this as index into a scale with a given number of steps per ocatve.

Discussion:

.grayCode

Returns:

the gray code for the number.

Discussion:

Binary Representation

.setBit(bitNumber, bool: true)

set nth bit to zero (bool = false) or one (bool = true)

.leadingZeroes

{ _CLZ }

.trailingZeroes

{ _CTZ }

.numBits

Returns:

number of required bits

Properties

.even

Returns:

true if dividable by 2 with no rest

.odd

Returns:

true if not dividable by 2 with no rest

Powers Of Two

.nextPowerOfTwo

Returns:

the next power of two greater than or equal to the receiver.

Discussion:

.isPowerOfTwo

Returns:

the whether the receiver is a power of two.

Discussion:

Prime Numbers

.nthPrime

Returns:

the nth prime number. The receiver must be from 0 to 6541.

Discussion:

.prevPrime

Returns:

the next prime less than or equal to the receiver up to 65521.

Discussion:

.nextPrime

Returns:

the next prime less than or equal to the receiver up to 65521.

Discussion:

.isPrime

Returns:

whether the receiver is prime.

Discussion:

.indexOfPrime

Returns:

the index of a prime number less than or equal to the receiver up to 65521. If the receiver is not a prime, the answer is nil.

Discussion:

Integer Math

.factorial

Returns:

the factorial of the receiver as an integer. This will overflow for numbers > 12 and throw an error. Floating point factorials can be used in such cases (see: SimpleNumber: -factorial).

Discussion:

Misc

.pidRunning

Returns:

a Boolean for whether or not the specified pid is running.

Discussion:

.lcmByGcd( ... args)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/miSCellaneous_lib/Classes/Sieves/lcmExtensions.sc

Calculates the least common multiple by using the greatest common divisor. This can avoid problems with large numbers. See Sieves and Psieve patterns: 4b

Arguments:

... args

Integers

.lcmByFactors( ... args)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/miSCellaneous_lib/Classes/Sieves/lcmExtensions.sc

Calculates the least common multiple by prime factors. This can avoid problems with large numbers. Returns an array with lcm as first item, an array with prime factors of lcm as second item and an array of receiver's and all arguments' prime factors. See Sieves and Psieve patterns: 4b

Arguments:

... args

Integers

Fourier Transform

.fftFreqs(sampleRate)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/SignalBox/Classes/extInteger.sc

Returns:

the Discrete Fourier Transform sample frequencies.

Discussion:

.rfftFreqs(sampleRate)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/SignalBox/Classes/extInteger.sc

Returns:

the Discrete Fourier Transform sample frequencies.

Discussion:

.dftFreqs(sampleRate)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/SignalBox/Classes/extInteger.sc

Returns:

the Discrete Fourier Transform sample frequencies.

Discussion:

Ambisonic Toolkit

.asHoaOrder

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/atk-sc3/Classes/extInteger.sc

Returns:

a new HoaOrder instance.

.asHoaDegree

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/atk-sc3/Classes/extInteger.sc

Returns:

a new HoaDegree instance.

Inherited instance methods

Undocumented instance methods

*(aNumber, adverb)

+(aNumber, adverb)

-(aNumber, adverb)

.allPartitions

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/MathLib/classes/various/extIntegerPartition.sc

.archiveAsCompileString

.asBus(rate: 'control', numChannels: 1, server)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/asBus.sc

.asFileSafeChar

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/crucial-library/Players/pathUtilities.sc

.asFileSafeString

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/crucial-library/Players/pathUtilities.sc

.asGroup

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/asGroup.sc

.asNodeID

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/asTarget.sc

.asPaddedString(size: 2, padChar: "0", padSide: 'left')

From extension in /usr/local/share/SuperCollider/Extensions/SC3plugins/LoopBufUGens/classes/LJP Classes/Extensions/Integer-asPaddedString.sc

.asStringToBase(base: 10, width: 8)

.asStringWithFrac(fracSize: 3)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/String/asStringWithFrac.sc

.asTarget

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/asTarget.sc

.asUnicode

.ascii

From extension in /home/stefan/.local/share/SuperCollider/Extensions/Strang/Strang.sc

.clip(lo, hi)

.controlFlag

From extension in /home/stefan/.local/share/SuperCollider/CVmin/classes/extMisc.sc

.differentialManchesterEncode(numBits: 8, phase: 0)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/redSys/redTools/RedDifferentialManchesterCode.sc

.differentialManchesterEncodeNegative(numBits: 8, phase: 1)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/redSys/redTools/RedDifferentialManchesterCode.sc

.enum(pool, function: true, evalAtZero: false, type: 0, order: true, maxNum: inf)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/miSCellaneous_lib/Classes/Enumeration/extInteger.sc

.exit

.fold(lo, hi)

.generate(function)

.hash

.isAlt

.isCantorNumber

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/MathLib/classes/various/isCantorNumber.sc

.isCaps

.isCmd

.isCtrl

.isFun

.isHelp

.isInteger

.isNumPad

.isShift

.log2Ceil

.manchesterEncode(numBits: 8)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/redSys/redTools/RedManchesterCode.sc

.mapToCantor

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/MathLib/classes/various/isCantorNumber.sc

.optionFlag

From extension in /home/stefan/.local/share/SuperCollider/CVmin/classes/extMisc.sc

.schedBundle(bundle, server, timeOfRequest)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/Control/schedBundle.sc

.shiftFlag

From extension in /home/stefan/.local/share/SuperCollider/CVmin/classes/extMisc.sc

.toSieve

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/miSCellaneous_lib/Classes/Sieves/toSieve.sc

.wrand(probabilities)

From extension in /home/stefan/.local/share/SuperCollider/Extensions/wrand.sc

.wrap(lo, hi)