API  1.0.0
CPDecimalNumber Class Reference

Decimal floating point number. More...

#import <CPDecimalNumber.h>

+ Inheritance diagram for CPDecimalNumber:

Instance Methods

(BOOL) - boolValue
 
(char) - charValue
 
(CPComparisonResult) - compare:
 
(CPDecimalNumber- decimalNumberByAdding:
 
(CPDecimalNumber- decimalNumberByAdding:withBehavior:
 
(CPDecimalNumber- decimalNumberByDividingBy:
 
(CPDecimalNumber- decimalNumberByDividingBy:withBehavior:
 
(CPDecimalNumber- decimalNumberByMultiplyingBy:
 
(CPDecimalNumber- decimalNumberByMultiplyingBy:withBehavior:
 
(CPDecimalNumber- decimalNumberByMultiplyingByPowerOf10:
 
(CPDecimalNumber- decimalNumberByMultiplyingByPowerOf10:withBehavior:
 
(CPDecimalNumber- decimalNumberByRaisingToPower:
 
(CPDecimalNumber- decimalNumberByRaisingToPower:withBehavior:
 
(CPDecimalNumber- decimalNumberByRoundingAccordingToBehavior:
 
(CPDecimalNumber- decimalNumberBySubtracting:
 
(CPDecimalNumber- decimalNumberBySubtracting:withBehavior:
 
(CPDecimal) - decimalValue
 
(CPString- description
 
(CPString- descriptionWithLocale:
 
(double) - doubleValue
 
(void) - encodeWithCoder:
 
(float) - floatValue
 
(id) - init
 
(id) - initWithBool:
 
(id) - initWithChar:
 
(id) - initWithCoder:
 
(id) - initWithDecimal:
 
(id) - initWithDouble:
 
(id) - initWithFloat:
 
(id) - initWithInt:
 
(id) - initWithLong:
 
(id) - initWithLongLong:
 
(id) - initWithMantissa:exponent:isNegative:
 
(id) - initWithShort:
 
(id) - initWithString:
 
(id) - initWithString:locale:
 
(id) - initWithUnsignedChar:
 
(id) - initWithUnsignedInt:
 
(id) - initWithUnsignedLong:
 
(id) - initWithUnsignedLongLong:
 
(id) - initWithUnsignedShort:
 
(int) - intValue
 
(BOOL) - isEqualToNumber:
 
(long long) - longLongValue
 
(long) - longValue
 
(CPString- objCType
 
(short) - shortValue
 
(CPString- stringValue
 
(CPString- UID
 
(unsigned char) - unsignedCharValue
 
(unsigned int) - unsignedIntValue
 
(unsigned long) - unsignedLongValue
 
(unsigned short) - unsignedShortValue
 
- Instance Methods inherited from CPNumber
(int) - integerValue
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray) - exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(BOOL) - isEqual:
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(void) - performSelector:withObject:afterDelay:
 
(void) - performSelector:withObject:afterDelay:inModes:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(id) + alloc
 
(CPDecimalNumber+ decimalNumberWithDecimal:
 
(CPDecimalNumber+ decimalNumberWithMantissa:exponent:isNegative:
 
(CPDecimalNumber+ decimalNumberWithString:
 
(CPDecimalNumber+ decimalNumberWithString:locale:
 
(id) + defaultBehavior
 
(CPDecimalNumber+ maximumDecimalNumber
 
(CPDecimalNumber+ minimumDecimalNumber
 
(CPDecimalNumber+ notANumber
 
(id) + numberWithBool:
 
(id) + numberWithChar:
 
(id) + numberWithDouble:
 
(id) + numberWithFloat:
 
(id) + numberWithInt:
 
(id) + numberWithLong:
 
(id) + numberWithLongLong:
 
(id) + numberWithShort:
 
(id) + numberWithUnsignedChar:
 
(id) + numberWithUnsignedInt:
 
(id) + numberWithUnsignedLong:
 
(id) + numberWithUnsignedLongLong:
 
(id) + numberWithUnsignedShort:
 
(CPDecimalNumber+ one
 
(void) + setDefaultBehavior:
 
(CPDecimalNumber+ zero
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(void) + cancelPreviousPerformRequestsWithTarget:
 
(void) + cancelPreviousPerformRequestsWithTarget:selector:object:
 
(Class) + class
 
(BOOL) + conformsToProtocol:
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesImplementSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isBindingExclusive:
 
(BOOL) + isSubclassOfClass:
 
(CPSet) + keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + object:performSelector:withObject:afterDelay:inModes:
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Detailed Description

Decimal floating point number.

This class represents a decimal floating point number and the relevant mathematical operations to go with it. It guarantees accuracy up to 38 digits in the mantissa/coefficient and can handle numbers in the range: +/- 99999999999999999999999999999999999999 x 10^(127/-128) Methods are available for: Addition, Subtraction, Multiplication, Division, Powers and Rounding. Exceptions can be thrown on: Overflow, Underflow, Loss of Precision (rounding) and Divide by zero, the behaviour of which is controlled via the CPDecimalNumberHandler class.

Note: The aim here is to try to produce the exact same output as Cocoa. However, this is effectively not possible but to get as close as possible we must perform our calculations in a way such that we even get the same rounding errors building up, say when computing large powers which require many multiplications. The code here almost matches the results of Cocoa but there are some small differences as outlined below:

An example where a small rounding error difference creeps in: For the calculation (0.875 ^ 101) the result becomes: In Cocoa: 0.00000(13893554059925661274821814636807535200)1 the 38 digits are bracketed, the extra 39th digit in Cocoa is explained below. In Cappuccino: 0.00000(13893554059925661274821814636807535204) Difference: 4e-41

Since, in Cocoa, NSDecimalNumber uses a binary internal format for the mantissa (coefficient) the maximum it can store before truly losing precision is actually 2^128, which is a 39 digit number. After this rounding and exponent changes occur. In our implementation each digit is stored separately hence the mantissa maximum value is the maximum possible 38 digit number. Obviously Apple can only say precision is guaranteed to 38 digits cause at some point in the 39 digits numbers rounding starts. Hence there will be inherent differences between Cocoa and Cappuccino answers if rounding occurs (see above example). They both still provide the same 38 digit guarantee however.

So the actual range of NSDecimal is +/- 340282366920938463463374607431768211455 x 10^(127/-128) (Notice this is 39 digits) Compared to in Cappuccino: +/- 99999999999999999999999999999999999999 x 10^(127/-128)

Definition at line 2 of file CPDecimalNumber.h.

Method Documentation

◆ alloc()

+ (id) alloc
implementation

Create a new CPDecimalNumber object uninitialised. Note: even though CPDecimalNumber inherits from CPNumber it is not toll free bridged to a JS type as CPNumber is.

Returns
a new CPDecimalNumber instance

Reimplemented from CPNumber.

Definition at line 324 of file CPDecimalNumber.j.

◆ boolValue()

- (BOOL) boolValue
implementation

Returns a JS bool representation.

Returns
a JS bool

Reimplemented from CPNumber.

Definition at line 864 of file CPDecimalNumber.j.

◆ charValue()

- (char) charValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 873 of file CPDecimalNumber.j.

◆ compare:()

- (CPComparisonResult) compare: (CPNumber aNumber
implementation

Compare the receiver CPDecimalNumber to aNumber. This is a CPNumber or subclass. Returns CPOrderedDescending, CPOrderedAscending or CPOrderedSame.

Parameters
aNumberan object of kind CPNumber to compare against.
Returns
result from CPComparisonResult enum.

Reimplemented from CPNumber.

Definition at line 792 of file CPDecimalNumber.j.

◆ decimalNumberByAdding:()

- (CPDecimalNumber) decimalNumberByAdding: (CPDecimalNumber decimalNumber
implementation

Returns a new CPDecimalNumber object with the result of the summation of the receiver object and decimalNumber. If overflow occurs then the consequence depends on the current default CPDecimalNumberHandler.

Parameters
decimalNumberthe decimal number to add to the receiver
Returns
a new CPDecimalNumber object

Definition at line 549 of file CPDecimalNumber.j.

◆ decimalNumberByAdding:withBehavior:()

- (CPDecimalNumber) decimalNumberByAdding: (CPDecimalNumber decimalNumber
withBehavior: (id <CPDecimalNumberBehaviors>)  behavior 
implementation

Returns a new CPDecimalNumber object with the result of the summation of the receiver object and decimalNumber. If overflow occurs then the consequence depends on the CPDecimalNumberHandler object behavior.

Parameters
decimalNumberthe decimal number to add to the receiver
behaviora CPDecimalNumberHandler object
Returns
a new CPDecimalNumber object

Definition at line 562 of file CPDecimalNumber.j.

◆ decimalNumberByDividingBy:()

- (CPDecimalNumber) decimalNumberByDividingBy: (CPDecimalNumber decimalNumber
implementation

Returns a new CPDecimalNumber object with the result of dividing the receiver object by decimalNumber. If underflow, divide by zero or loss of precision occurs then the consequence depends on the current default CPDecimalNumberHandler object.

Parameters
decimalNumberthe decimal number to divide the the receiver by
Returns
a new CPDecimalNumber object

Definition at line 623 of file CPDecimalNumber.j.

◆ decimalNumberByDividingBy:withBehavior:()

- (CPDecimalNumber) decimalNumberByDividingBy: (CPDecimalNumber decimalNumber
withBehavior: (id <CPDecimalNumberBehaviors>)  behavior 
implementation

Returns a new CPDecimalNumber object with the result of dividing the receiver object by decimalNumber. If underflow, divide by zero or loss of precision occurs then the consequence depends on the CPDecimalNumberHandler object behavior.

Parameters
decimalNumberthe decimal number to divide the the receiver by
behaviora CPDecimalNumberHandler object
Returns
a new CPDecimalNumber object

Definition at line 637 of file CPDecimalNumber.j.

◆ decimalNumberByMultiplyingBy:()

- (CPDecimalNumber) decimalNumberByMultiplyingBy: (CPDecimalNumber decimalNumber
implementation

Returns a new CPDecimalNumber object with the result of multiplying the receiver object by decimalNumber. If overflow or loss of precision occurs then the consequence depends on the current default CPDecimalNumberHandler object.

Parameters
decimalNumberthe decimal number to multiply the the receiver by
Returns
a new CPDecimalNumber object

Definition at line 660 of file CPDecimalNumber.j.

◆ decimalNumberByMultiplyingBy:withBehavior:()

- (CPDecimalNumber) decimalNumberByMultiplyingBy: (CPDecimalNumber decimalNumber
withBehavior: (id <CPDecimalNumberBehaviors>)  behavior 
implementation

Returns a new CPDecimalNumber object with the result of multiplying the receiver object by decimalNumber. If overflow or loss of precision occurs then the consequence depends on the CPDecimalNumberHandler object behavior.

Parameters
decimalNumberthe decimal number to multiply the the receiver by
behaviora CPDecimalNumberHandler object
Returns
a new CPDecimalNumber object

Definition at line 674 of file CPDecimalNumber.j.

◆ decimalNumberByMultiplyingByPowerOf10:()

- (CPDecimalNumber) decimalNumberByMultiplyingByPowerOf10: (short)  power
implementation

Returns a new CPDecimalNumber object with the result of multiplying the receiver object by (10 ^ power). If overflow, underflow or loss of precision occurs then the consequence depends on the current default CPDecimalNumberHandler object.

Parameters
powerthe power of 10 to multiply the receiver by
Returns
a new CPDecimalNumber object

Definition at line 698 of file CPDecimalNumber.j.

◆ decimalNumberByMultiplyingByPowerOf10:withBehavior:()

- (CPDecimalNumber) decimalNumberByMultiplyingByPowerOf10: (short)  power
withBehavior: (id <CPDecimalNumberBehaviors>)  behavior 
implementation

Returns a new CPDecimalNumber object with the result of multiplying the receiver object by (10 ^ power). If overflow, underflow or loss of precision occurs then the consequence depends on the CPDecimalNumberHandler object behavior.

Parameters
powerthe power of 10 to multiply the receiver by
behaviora CPDecimalNumberHandler object
Returns
a new CPDecimalNumber object

Definition at line 712 of file CPDecimalNumber.j.

◆ decimalNumberByRaisingToPower:()

- (CPDecimalNumber) decimalNumberByRaisingToPower: (unsigned)  power
implementation

Returns a new CPDecimalNumber object with the result of raising the receiver object to the power power. If overflow, underflow or loss of precision occurs then the consequence depends on the current default CPDecimalNumberHandler object.

Parameters
powerthe power to raise the receiver by
Returns
a new CPDecimalNumber object

Definition at line 736 of file CPDecimalNumber.j.

◆ decimalNumberByRaisingToPower:withBehavior:()

- (CPDecimalNumber) decimalNumberByRaisingToPower: (unsigned)  power
withBehavior: (id <CPDecimalNumberBehaviors>)  behavior 
implementation

Returns a new CPDecimalNumber object with the result of raising the receiver object to the power power. If overflow, underflow or loss of precision occurs then the consequence depends on the CPDecimalNumberHandler object behavior.

Parameters
powerthe power to raise the receiver by
behaviora CPDecimalNumberHandler object
Returns
a new CPDecimalNumber object

Definition at line 750 of file CPDecimalNumber.j.

◆ decimalNumberByRoundingAccordingToBehavior:()

- (CPDecimalNumber) decimalNumberByRoundingAccordingToBehavior: (id <CPDecimalNumberBehaviors>)  behavior
implementation

Returns a new CPDecimalNumber object with the result of rounding the number according to the rounding behavior specified by the CPDecimalNumberHandler object behavior.

Parameters
behaviora CPDecimalNumberHandler object
Returns
a new rounded CPDecimalNumber object

Definition at line 776 of file CPDecimalNumber.j.

◆ decimalNumberBySubtracting:()

- (CPDecimalNumber) decimalNumberBySubtracting: (CPDecimalNumber decimalNumber
implementation

Returns a new CPDecimalNumber object with the result of the subtraction of decimalNumber from the receiver object. If underflow or loss of precision occurs then the consequence depends on the current default CPDecimalNumberHandler.

Parameters
decimalNumberthe decimal number to subtract from the receiver
Returns
a new CPDecimalNumber object

Definition at line 585 of file CPDecimalNumber.j.

◆ decimalNumberBySubtracting:withBehavior:()

- (CPDecimalNumber) decimalNumberBySubtracting: (CPDecimalNumber decimalNumber
withBehavior: (id <CPDecimalNumberBehaviors>)  behavior 
implementation

Returns a new CPDecimalNumber object with the result of the subtraction of decimalNumber from the receiver object. If underflow or loss of precision occurs then the consequence depends on the CPDecimalNumberHandler object behavior.

Parameters
decimalNumberthe decimal number to subtract from the receiver
behaviora CPDecimalNumberHandler object
Returns
a new CPDecimalNumber object

Definition at line 599 of file CPDecimalNumber.j.

◆ decimalNumberWithDecimal:()

+ (CPDecimalNumber) decimalNumberWithDecimal: (CPDecimal)  dcm
implementation

Return a new CPDecimalNumber object with the contents of a CPDecimal object

Parameters
dcmthe CPDecimal object to copy
Returns
the new CPDecimalNumber object

Definition at line 415 of file CPDecimalNumber.j.

◆ decimalNumberWithMantissa:exponent:isNegative:()

+ (CPDecimalNumber) decimalNumberWithMantissa: (unsigned long long)  mantissa
exponent: (short)  exponent
isNegative: (BOOL)  flag 
implementation

Creates a new CPDecimalNumber object with the given mantissa and exponent. See -initWithMantissa:exponent:isNegative: for some extra notes.

Parameters
mantissathe mantissa of the decimal number
exponentthe exponent of the number
flagtrue if number is negative
Returns
the new CPDecimalNumber object

Definition at line 428 of file CPDecimalNumber.j.

◆ decimalNumberWithString:()

+ (CPDecimalNumber) decimalNumberWithString: (CPString numberValue
implementation

Creates a new CPDecimalNumber with a string. If the string is badly formed or outside of the acceptable range of a CPDecimal then the number is initialised to NaN.

Parameters
numberValuethe string to parse.
Returns
the new CPDecimalNumber object

Definition at line 440 of file CPDecimalNumber.j.

◆ decimalNumberWithString:locale:()

+ (CPDecimalNumber) decimalNumberWithString: (CPString numberValue
locale: (CPDictionary locale 
implementation

Creates a new CPDecimalNumber with a string using the given locale. If the string is badly formed or outside of the acceptable range of a CPDecimal then the number is initialised to NaN. NOTE: Locales are currently not supported.

Parameters
numberValuethe string to parse
localethe CPLocale object to use when parsing the number string
Returns
the new CPDecimalNumber object

Definition at line 454 of file CPDecimalNumber.j.

◆ decimalValue()

- (CPDecimal) decimalValue
implementation

Returns a new CPDecimal object (which effectively contains the internal decimal number representation).

Returns
a new CPDecimal number copy

Reimplemented from CPNumber.

Definition at line 844 of file CPDecimalNumber.j.

◆ defaultBehavior()

+ (id) defaultBehavior
implementation

Return the default CPDecimalNumberHandler object.

Returns
the default CPDecimalNumberHandler object

Definition at line 463 of file CPDecimalNumber.j.

◆ description()

- (CPString) description
implementation

Returns a string representation of the decimal number.

Returns
a CPString

Reimplemented from CPNumber.

Definition at line 814 of file CPDecimalNumber.j.

◆ descriptionWithLocale:()

- (CPString) descriptionWithLocale: (CPDictionary locale
implementation

Returns a string representation of the decimal number given the specified locale. Note: locales are currently unsupported

Parameters
localethe locale
Returns
a CPString

Reimplemented from CPNumber.

Definition at line 825 of file CPDecimalNumber.j.

◆ doubleValue()

- (double) doubleValue
implementation

Returns a JS float representation. Truncation may occur.

Returns
a JS float

Reimplemented from CPNumber.

Definition at line 854 of file CPDecimalNumber.j.

◆ encodeWithCoder:()

- (void) encodeWithCoder: (CPCoder aCoder
implementation

Called by CPCoder's encodeObject: to archive the object instance.

Parameters
aCodera CPCoder instance

Reimplemented from CPNumber.

Provided by category CPDecimalNumber(CPCoding).

Definition at line 1285 of file CPDecimalNumber.j.

◆ floatValue()

- (float) floatValue
implementation

Returns a JS float representation. Truncation may occur.

Returns
a JS float

Reimplemented from CPNumber.

Definition at line 883 of file CPDecimalNumber.j.

◆ init()

- (id) init
implementation

Initialise a CPDecimalNumber object with NaN

Returns
the reference to the receiver CPDecimalNumber

Reimplemented from CPObject.

Definition at line 335 of file CPDecimalNumber.j.

◆ initWithBool:()

- (id) initWithBool: (BOOL)  value
implementation

Initialise the receiver with a boolean value.

Parameters
valuea JS boolean value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1116 of file CPDecimalNumber.j.

◆ initWithChar:()

- (id) initWithChar: (char)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1128 of file CPDecimalNumber.j.

◆ initWithCoder:()

- (id) initWithCoder: (CPCoder aCoder
implementation

Called by CPCoder's decodeObject: to initialise the object with an archived one.

Parameters
aCodera CPCoder instance

Reimplemented from CPNumber.

Provided by category CPDecimalNumber(CPCoding).

Definition at line 1265 of file CPDecimalNumber.j.

◆ initWithDecimal:()

- (id) initWithDecimal: (CPDecimal)  dcm
implementation

Initialise a CPDecimalNumber object with the contents of a CPDecimal object

Parameters
dcmthe CPDecimal object to copy
Returns
the reference to the receiver CPDecimalNumber

Definition at line 345 of file CPDecimalNumber.j.

◆ initWithDouble:()

- (id) initWithDouble: (double)  value
implementation

Initialise the receiver with a float value.

Parameters
valuea JS float value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1138 of file CPDecimalNumber.j.

◆ initWithFloat:()

- (id) initWithFloat: (float)  value
implementation

Initialise the receiver with a float value.

Parameters
valuea JS float value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1148 of file CPDecimalNumber.j.

◆ initWithInt:()

- (id) initWithInt: (int)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1158 of file CPDecimalNumber.j.

◆ initWithLong:()

- (id) initWithLong: (long)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1168 of file CPDecimalNumber.j.

◆ initWithLongLong:()

- (id) initWithLongLong: (long long)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1178 of file CPDecimalNumber.j.

◆ initWithMantissa:exponent:isNegative:()

- (id) initWithMantissa: (unsigned long long)  mantissa
exponent: (short)  exponent
isNegative: (BOOL)  flag 
implementation

Initialise a CPDecimalNumber object with the given mantissa and exponent. Note: that since 'long long' doesn't exist in JS the mantissa is smaller than possible in Cocoa and can thus not create the full number range possible for a CPDecimal. Also note that at extreme cases where overflow or truncation will occur to the parameters in Cocoa this method produces different results to its Cocoa counterpart.

Parameters
mantissathe mantissa of the decimal number
exponentthe exponent of the number
flagtrue if number is negative
Returns
the reference to the receiver CPDecimalNumber

Definition at line 365 of file CPDecimalNumber.j.

◆ initWithShort:()

- (id) initWithShort: (short)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1188 of file CPDecimalNumber.j.

◆ initWithString:()

- (id) initWithString: (CPString numberValue
implementation

Initialise a CPDecimalNumber with a string. If the string is badly formed or outside of the acceptable range of a CPDecimal then the number is initialised to NaN.

Parameters
numberValuethe string to parse.
Returns
the reference to the receiver CPDecimalNumber

Definition at line 385 of file CPDecimalNumber.j.

◆ initWithString:locale:()

- (id) initWithString: (CPString numberValue
locale: (CPDictionary locale 
implementation

Initialise a CPDecimalNumber with a string using the given locale. If the string is badly formed or outside of the acceptable range of a CPDecimal then the number is initialised to NaN. NOTE: Locales are currently not supported.

Parameters
numberValuethe string to parse
localethe CPLocale object to use when parsing the number string
Returns
the reference to the receiver CPDecimalNumber

Definition at line 399 of file CPDecimalNumber.j.

◆ initWithUnsignedChar:()

- (id) initWithUnsignedChar: (unsigned char)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1198 of file CPDecimalNumber.j.

◆ initWithUnsignedInt:()

- (id) initWithUnsignedInt: (unsigned)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1208 of file CPDecimalNumber.j.

◆ initWithUnsignedLong:()

- (id) initWithUnsignedLong: (unsigned long)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1218 of file CPDecimalNumber.j.

◆ initWithUnsignedLongLong:()

- (id) initWithUnsignedLongLong: (unsigned long long)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Definition at line 1228 of file CPDecimalNumber.j.

◆ initWithUnsignedShort:()

- (id) initWithUnsignedShort: (unsigned short)  value
implementation

Initialise the receiver with an int value.

Parameters
valuea JS int value
Returns
a reference to the initialised object

Reimplemented from CPNumber.

Definition at line 1238 of file CPDecimalNumber.j.

◆ intValue()

- (int) intValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 893 of file CPDecimalNumber.j.

◆ isEqualToNumber:()

- (BOOL) isEqualToNumber: (CPNumber aNumber
implementation

Compare the receiver CPDecimalNumber to aNumber and return YES if equal.

Parameters
aNumberan object of kind CPNumber to compare against.
Returns
a boolean

Reimplemented from CPNumber.

Definition at line 976 of file CPDecimalNumber.j.

◆ longLongValue()

- (long long) longLongValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 903 of file CPDecimalNumber.j.

◆ longValue()

- (long) longValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 913 of file CPDecimalNumber.j.

◆ maximumDecimalNumber()

+ (CPDecimalNumber) maximumDecimalNumber
implementation

Returns a new CPDecimalNumber with the maximum permissible decimal number value. Note: this is different to the number Cocoa returns. See CPDecimalNumber class description for details.

Returns
a new CPDecimalNumber object

Definition at line 484 of file CPDecimalNumber.j.

◆ minimumDecimalNumber()

+ (CPDecimalNumber) minimumDecimalNumber
implementation

Returns a new CPDecimalNumber with the minimum permissible decimal number value. Note: this is different to the number Cocoa returns. See CPDecimalNumber class description for details.

Returns
a new CPDecimalNumber object

Definition at line 495 of file CPDecimalNumber.j.

◆ notANumber()

+ (CPDecimalNumber) notANumber
implementation

Returns a new CPDecimalNumber initialised to NaN.

Returns
a new CPDecimalNumber object

Definition at line 504 of file CPDecimalNumber.j.

◆ numberWithBool:()

+ (id) numberWithBool: (BOOL)  aBoolean
implementation

Create a new CPDecimalNumber initialised with aBoolean.

Parameters
aBooleana JS boolean value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 986 of file CPDecimalNumber.j.

◆ numberWithChar:()

+ (id) numberWithChar: (char)  aChar
implementation

Create a new CPDecimalNumber initialised with aChar.

Parameters
aChara JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 996 of file CPDecimalNumber.j.

◆ numberWithDouble:()

+ (id) numberWithDouble: (double)  aDouble
implementation

Create a new CPDecimalNumber initialised with aDouble.

Parameters
aDoublea JS float value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1006 of file CPDecimalNumber.j.

◆ numberWithFloat:()

+ (id) numberWithFloat: (float)  aFloat
implementation

Create a new CPDecimalNumber initialised with aFloat.

Parameters
aFloata JS float value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1016 of file CPDecimalNumber.j.

◆ numberWithInt:()

+ (id) numberWithInt: (int)  anInt
implementation

Create a new CPDecimalNumber initialised with anInt.

Parameters
anInta JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1026 of file CPDecimalNumber.j.

◆ numberWithLong:()

+ (id) numberWithLong: (long)  aLong
implementation

Create a new CPDecimalNumber initialised with aLong.

Parameters
aLonga JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1036 of file CPDecimalNumber.j.

◆ numberWithLongLong:()

+ (id) numberWithLongLong: (long long)  aLongLong
implementation

Create a new CPDecimalNumber initialised with aLongLong.

Parameters
aLongLonga JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1046 of file CPDecimalNumber.j.

◆ numberWithShort:()

+ (id) numberWithShort: (short)  aShort
implementation

Create a new CPDecimalNumber initialised with aShort.

Parameters
aShorta JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1056 of file CPDecimalNumber.j.

◆ numberWithUnsignedChar:()

+ (id) numberWithUnsignedChar: (unsigned char)  aChar
implementation

Create a new CPDecimalNumber initialised with aChar.

Parameters
aChara JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1066 of file CPDecimalNumber.j.

◆ numberWithUnsignedInt:()

+ (id) numberWithUnsignedInt: (unsigned)  anUnsignedInt
implementation

Create a new CPDecimalNumber initialised with anUnsignedInt.

Parameters
anUnsignedInta JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1076 of file CPDecimalNumber.j.

◆ numberWithUnsignedLong:()

+ (id) numberWithUnsignedLong: (unsigned long)  anUnsignedLong
implementation

Create a new CPDecimalNumber initialised with aChar.

Parameters
aChara JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1086 of file CPDecimalNumber.j.

◆ numberWithUnsignedLongLong:()

+ (id) numberWithUnsignedLongLong: (unsigned long)  anUnsignedLongLong
implementation

Create a new CPDecimalNumber initialised with anUnsignedLongLong.

Parameters
anUnsignedLongLonga JS int value
Returns
a new CPDecimalNumber object

Definition at line 1096 of file CPDecimalNumber.j.

◆ numberWithUnsignedShort:()

+ (id) numberWithUnsignedShort: (unsigned short)  anUnsignedShort
implementation

Create a new CPDecimalNumber initialised with anUnsignedShort.

Parameters
anUnsignedShorta JS int value
Returns
a new CPDecimalNumber object

Reimplemented from CPNumber.

Definition at line 1106 of file CPDecimalNumber.j.

◆ objCType()

- (CPString) objCType
implementation

The objective C type string. For compatibility reasons

Returns
returns a CPString containing "d"

Definition at line 805 of file CPDecimalNumber.j.

◆ one()

+ (CPDecimalNumber) one
implementation

Returns a new CPDecimalNumber initialised to one (1.0).

Returns
a new CPDecimalNumber object

Definition at line 522 of file CPDecimalNumber.j.

◆ setDefaultBehavior:()

+ (void) setDefaultBehavior: (id <CPDecimalNumberBehaviors>)  behavior
implementation

Set the default CPDecimalNumberHandler object. This is a framework wide setting. All subsequent decimal number operations will use this behaviour.

Parameters
behaviorthe new default CPDecimalNumberHandler object

Definition at line 473 of file CPDecimalNumber.j.

◆ shortValue()

- (short) shortValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 923 of file CPDecimalNumber.j.

◆ stringValue()

- (CPString) stringValue
implementation

Returns a string representation of the decimal number.

Returns
a CPString

Reimplemented from CPNumber.

Definition at line 834 of file CPDecimalNumber.j.

◆ UID()

- (CPString) UID
implementation

Reimplemented from CPNumber.

Definition at line 529 of file CPDecimalNumber.j.

◆ unsignedCharValue()

- (unsigned char) unsignedCharValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 933 of file CPDecimalNumber.j.

◆ unsignedIntValue()

- (unsigned int) unsignedIntValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 943 of file CPDecimalNumber.j.

◆ unsignedLongValue()

- (unsigned long) unsignedLongValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 953 of file CPDecimalNumber.j.

◆ unsignedShortValue()

- (unsigned short) unsignedShortValue
implementation

Returns a JS int representation. Truncation may occur.

Returns
a JS int

Reimplemented from CPNumber.

Definition at line 963 of file CPDecimalNumber.j.

◆ zero()

+ (CPDecimalNumber) zero
implementation

Returns a new CPDecimalNumber initialised to zero (0.0).

Returns
a new CPDecimalNumber object

Definition at line 513 of file CPDecimalNumber.j.


The documentation for this class was generated from the following files: