Maturity Index: Relatively mature
+newReturns a new integer equal to zero. The instance method zero returns a shared, zero integer object.
See also: - zero
+str:(STR)aStringReturns a new integer from the decimal representation aString, or returns nil if aString doesn't contain decimal characters (with optional unary minus sign).
+int:(int)intValueReturns a new integer with value equal to intValue.
+factorial:(int)nReturns a new integer object that is the n-th factorial.
+fibonacci:(int)nReturns a new object that is the n-th Fibonacci number. (Not implemented).
-copyMakes a copy of the digits.
-deepCopyFor integer objects, deepCopy is equivalent to copy.
-releaseFrees the array of digits of the integer object.
- (unsigned)hashReturns a small integer that is the same for objects that are equal (in the sense of isEqual:).
- (BOOL)isEqual:b
- (int)numDigitsReturns the number of DIGIT's in the integer. Returns zero if the integer is zero. The leading digit of an integer is at position numDigits minus one.
- (BOOL)isDigitWhether the integer consists of a single digit. If the integer is zero, this method returns NO. The method ignores the sign of the integer.
See also: digitValue
-insertDigit:(DIGIT)dInserts d as last digit, shifting the other digits one position up. The method doesn't insert anything if both the integer and d are equal to zero.
- (DIGIT)removeDigitRemoves and returns the last digit, shifting the other digits one position down. The method returns zero if the integer is equal to zero.
- (DIGIT)digitAt:(int)iReturns the digit at position i. The leading digit is position numDigits minus one. The last digit is at position zero. Returns 0 if the index is less than zero or equal to or greater than numDigits.
- (DIGIT)lastDigitReturns the least significant digit of the integer, the digit at position 0. Returns 0 if the integer is zero.
- (DIGIT)leadingDigitReturns the most significant digit of the integer, the digit at position numDigits minus one. The leading digit of a nonzero integer is never zero. The method returns 0 if the integer is zero.
- (STR)strReturns the decimal representation of the integer as a NULL-terminated string of characters. The string is automatically disposed off when freeing the integer, or when modifying the integer with methods that work destructively on the integer such as removeDigit or insertDigit:.
-str:(STR)aStringReturns a new integer from the decimal representation aString, or returns nil if aString doesn't contain decimal characters (with optional unary minus sign).
-asNumericalReturns a new instance of the Float class whose float value is equal to that of the integer.
See also: floatValue
-asModp:(unsigned short)pReturns a new instance of the IntegerModp class whose value is equal to that of the integer modulo p (with p a small prime number). Negative integers are mapped to the opposite (mod p) of their absolute value.
See also: IntegerModp
- (DIGIT)digitValueEquivalent to lastDigit. This method ignores the sign of the integer i.e., for a negative integer that consists of just one digit, it returns the absolute value of the integer.
-digitValue:(DIGIT)aValueReturns a new (positive) integer object, with value equal to aValue.
- (unsigned long)ulongValueReturns the two last digits of the integer as an unsigned long value.
-ulongValue:(unsigned long)aValueReturns a (positive) integer with value as unsigned long equal to aValue.
- (int)intValueReturns the value of the integer as int value, if possible. If the integer is too large to represented as int, the method returns INT_MIN or INT_MAX depending on the sign of the integer.
-intValue:(int)aValueReturns a new integer with value equal to aValue.
- (double)doubleValueReturns the integer as a floating-point double value, if possible. If the integer is too big to be represented as double, the method returns DBL_MIN or DBL_MAX depending on the sign of the integer.
- (float)floatValueReturns the integer as a floating-point float value, if possible. If the integer is too big to be represented as float, the method returns FLT_MIN or FLT_MAX depending on the sign of the integer.
- (int)signReturns plus one if the object is positive (greater than zero), zero if zero and minus one if negative (less than zero).
- (int)compare:bReturns -1, 0, or +1 if the object is respectively less than, equal to, or greater than b. Returns 0 for pointer equal objects.
-zeroReturns a copy of a shared integer instance with value equal to zero.
- (BOOL)isZeroWhether the object is equal to zero.
- (BOOL)isOpposite:bWhether the object is the opposite of b.
-negateReturns the opposite of the object.
-doubleReturns a new object, equal to the object multiplied by two i.e., added to itself.
-add:bAdds b to the object. Returns a new object.
-subtract:bSubtracts b from the object. Returns a new object.
-addDigit:(DIGIT)dReturns a new integer that is the sum of the integer self and the digit d.
-subtractDigit:(DIGIT)dReturns a new integer that is the equal to the integer self minus the digit d.
-oneReturns a copy of a shared integer instance with value equal to one.
-minusOneReturns a copy of the integer minus one.
- (BOOL)isOneWhether the object is equal to one.
- (BOOL)isMinusOneWhether the object is equal to minus one.
-squareReturns the square of the object i.e., a new object equal to the original object multiplied by itself.
-multiply:bReturns a new object, the product of the object multiplied (to the right) by b. If the objects are pointer equal, this method is equivalent to square.
-multiplyDigit:(DIGIT)dReturns the product of the integer and the digit d (the product is a new object).
-inverseReturns nil, except if the integer is one or minus one, in which case the method returns a copy of the object itself.
-divide:bReturns the exact quotient on division by b. Returns nil if the divisor b is zero or if the division is not exact (when the remainder is not zero).
See also: quotient:
-divideDigit:(DIGIT)bReturns the exact quotient on division by the digit b. Returns nil if the divisor b is zero or if the division is not exact (when the remainder is not zero).
-quotientDigit:(DIGIT)bReturns the quotient on division by the digit b; the division need not necessarily be exact. Returns nil if b is equal to zero.
-remainder:bquotient:(id *)qReturns the remainder and, if a non-NULL pointer is passed for q, the quotient on division of the dividend self by a divisor b. Both remainder and quotient are new integer objects. The remainder is signed i.e., its sign is the same as the sign of the dividend; the relation dividend == quotient divisor + remainder holds for all integers.
-quotientDigit:(DIGIT)dremainder:(DIGIT *)rReturns the quotient and, if a non-NULL pointer is passed along for r, the unsigned remainder on division by a digit d; the relation dividend == quotient divisor + remainder does not hold if the dividend is negative.
- (DIGIT)remainderDigit:(DIGIT)dReturns the unsigned remainder on division by a digit d i.e., the sign of the object is ignored. The divisor d shouldn't be equal to zero.
- (BOOL)isEvenWhether the integer is even i.e., zero or divisible by two.
- (BOOL)isOddWhether the integer is odd i.e., not divisible by two.
-gcd:bReturns a new (non-negative) integer, the greatest common divisor of the two integers, computed by the Euclidean algorithm.
- (BOOL)printsLeadingSignReturns YES if the integer is negative.
-printOn:(IOD)aFilePrints the integer in decimal representation to aFile.