API 0.9.5
CPDecimalNumberHandler Class Reference

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

#import <CPDecimalNumberHandler.h>

Inheritance diagram for CPDecimalNumberHandler:

List of all members.

Instance Methods

(void) - encodeWithCoder:
(CPDecimalNumber- exceptionDuringOperation:error:leftOperand:rightOperand:
(id) - init
(id) - initWithCoder:
(id) - initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:
(CPRoundingMode) - roundingMode
(short) - scale

Class Methods

(id) + decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:
(id) + defaultDecimalNumberHandler

Detailed Description

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

Definition at line 32 of file CPDecimalNumber.j.


Method Documentation

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

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.

+ (id) defaultDecimalNumberHandler

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.

- (void) encodeWithCoder: (CPCoder aCoder

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

Parameters:
aCodera CPCoder instance

Definition at line 230 of file CPDecimalNumber.j.

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

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

Definition at line 166 of file CPDecimalNumber.j.

- (id) init

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

Definition at line 49 of file CPDecimalNumber.j.

- (id) initWithCoder: (CPCoder aCoder

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

Parameters:
aCodera CPCoder instance

Definition at line 211 of file CPDecimalNumber.j.

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

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.

- (CPRoundingMode) roundingMode

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

Returns:
the current rounding mode

Definition at line 134 of file CPDecimalNumber.j.

- (short) scale

Returns the number of digits allowed after the decimal point.

Returns:
the current number of digits

Definition at line 143 of file CPDecimalNumber.j.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines