API  0.9.10
CPDecimalNumberHandler Class Reference

Decimal floating point number exception and rounding behavior. This class is mutable. More...

#import <CPDecimalNumberHandler.h>

+ Inheritance diagram for CPDecimalNumberHandler:

Instance Methods

(void) - encodeWithCoder:
 
(CPDecimalNumber- exceptionDuringOperation:error:leftOperand:rightOperand:
 
(id) - init
 
(id) - initWithCoder:
 
(id) - initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:
 
(CPRoundingMode) - roundingMode
 
(short) - scale
 
- 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
 
(CPString- description
 
(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:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(id) + decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:
 
(id) + defaultDecimalNumberHandler
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + alloc
 
(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 exception and rounding behavior. This class is mutable.

Definition at line 32 of file CPDecimalNumber.j.

Method Documentation

◆ decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:()

+ (id) decimalNumberHandlerWithRoundingMode: (CPRoundingMode)  roundingMode
scale: (short)  scale
raiseOnExactness: (BOOL)  exact
raiseOnOverflow: (BOOL)  overflow
raiseOnUnderflow: (BOOL)  underflow
raiseOnDivideByZero: (BOOL)  divideByZero 
implementation

Create a new CPDecimalNumberHandler object with the parameters specified. This class handles the behaviour of the decimal number calculation engine on certain exception. For more details see -initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:

Definition at line 101 of file CPDecimalNumber.j.

◆ defaultDecimalNumberHandler()

+ (id) defaultDecimalNumberHandler
implementation

Return the default Cappuccino CPDecimalNumberHandler object instance.

Returns
the default CPDecimalNumberHandler object reference with Rounding = CPRoundPlain, Scale = 0 and Raise on [exactness, overflow, underflow, divide by zero] = [no, yes, yes, yes]

Definition at line 117 of file CPDecimalNumber.j.

◆ encodeWithCoder:()

- (void) encodeWithCoder: (CPCoder aCoder
implementation

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

Parameters
aCodera CPCoder instance

Provided by category CPDecimalNumberHandler(CPCoding).

Definition at line 255 of file CPDecimalNumber.j.

◆ exceptionDuringOperation:error:leftOperand:rightOperand:()

- (CPDecimalNumber) exceptionDuringOperation: (SEL)  operation
error: (CPCalculationError)  error
leftOperand: (CPDecimalNumber leftOperand
rightOperand: (CPDecimalNumber rightOperand 
implementation

This method is invoked by the framework when an exception occurs on a decimal operation. Depending on the specified behaviour of the CPDecimalNumberHandler this will throw exceptions accordingly with formatted error messages.

Parameters
operationthe selector of the method of the operation being performed when the exception occurred
errorthe actual error type. From the CPCalculationError enum: CPCalculationNoError, CPCalculationLossOfPrecision, CPCalculationOverflow, CPCalculationUnderflow, CPCalculationDivideByZero
leftOperandthe CPDecimalNumber left-hand side operand used in the calculation that caused the exception
rightOperandthe CPDecimalNumber right-hand side operand used in the calculation that caused the exception
Returns
if appropriate a CPDecimalNumber is returned (either the maximum, minimum or NaN values), or nil

Provided by category CPDecimalNumberHandler(CPDecimalNumberBehaviors).

Definition at line 180 of file CPDecimalNumber.j.

◆ init()

- (id) init
implementation

Initialise a CPDecimalNumberHandler with 'Rounding' = CPRoundPlain, 'Scale' = 0 and 'Raise On [exactness, overflow, underflow, divide by zero]' = [no, yes, yes, yes].

Returns
the receiver CPDecimalNumberHandler object reference

Reimplemented from CPObject.

Definition at line 49 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

Provided by category CPDecimalNumberHandler(CPCoding).

Definition at line 236 of file CPDecimalNumber.j.

◆ initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:()

- (id) initWithRoundingMode: (CPRoundingMode)  roundingMode
scale: (short)  scale
raiseOnExactness: (BOOL)  exact
raiseOnOverflow: (BOOL)  overflow
raiseOnUnderflow: (BOOL)  underflow
raiseOnDivideByZero: (BOOL)  divideByZero 
implementation

Initialise a CPDecimalNumberHandler object with the parameters specified. This class handles the behaviour of the decimal number calculation engine on certain exceptions.

Parameters
roundingModethe technique used for rounding (see CPRoundingMode)
scaleThe number of digits after the decimal point that a number which is rounded should have
exactIf true, a change in precision (i.e. rounding) will cause a CPDecimalNumberExactnessException exception to be raised, else they are ignored
overflowIf true, a calculation overflow will cause a CPDecimalNumberOverflowException exception to be raised, else the maximum possible valid number is returned
underflowIf true, a calculation underflow will cause a CPDecimalNumberUnderflowException exception to be raised, else the minimum possible valid number is returned
divideByZeroIf true, a divide by zero will cause a CPDecimalNumberDivideByZeroException exception to be raised, else a NotANumber (NaN) CPDecimal is returned
Returns
the reference to the receiver CPDecimalNumberHandler

Definition at line 80 of file CPDecimalNumber.j.

◆ roundingMode()

- (CPRoundingMode) roundingMode
implementation

Returns the current rounding mode. One of CPRoundingMode enum: CPRoundPlain, CPRoundDown, CPRoundUp, CPRoundBankers.

Returns
the current rounding mode

Provided by category CPDecimalNumberHandler(CPDecimalNumberBehaviors).

Definition at line 148 of file CPDecimalNumber.j.

◆ scale()

- (short) scale
implementation

Returns the number of digits allowed after the decimal point.

Returns
the current number of digits

Provided by category CPDecimalNumberHandler(CPDecimalNumberBehaviors).

Definition at line 157 of file CPDecimalNumber.j.


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