![]() |
API 0.9.5
|
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 |
Class Methods | |
| (id) | + decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero: |
| (id) | + defaultDecimalNumberHandler |
Decimal floating point number exception and rounding behavior. This class is mutable.
Definition at line 32 of file CPDecimalNumber.j.
| + (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.
Definition at line 117 of file CPDecimalNumber.j.
| - (void) encodeWithCoder: | (CPCoder) | aCoder |
Called by CPCoder's encodeObject: to archive the object instance.
| aCoder | a 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.
| operation | the selector of the method of the operation being performed when the exception occurred |
| error | the actual error type. From the CPCalculationError enum: CPCalculationNoError, CPCalculationLossOfPrecision, CPCalculationOverflow, CPCalculationUnderflow, CPCalculationDivideByZero |
| leftOperand | the CPDecimalNumber left-hand side operand used in the calculation that caused the exception |
| rightOperand | the CPDecimalNumber right-hand side operand used in the calculation that caused the exception |
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].
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.
| aCoder | a 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.
| roundingMode | the technique used for rounding (see CPRoundingMode) |
| scale | The number of digits after the decimal point that a number which is rounded should have |
| exact | If true, a change in precision (i.e. rounding) will cause a CPDecimalNumberExactnessException exception to be raised, else they are ignored |
| overflow | If true, a calculation overflow will cause a CPDecimalNumberOverflowException exception to be raised, else the maximum possible valid number is returned |
| underflow | If true, a calculation underflow will cause a CPDecimalNumberUnderflowException exception to be raised, else the minimum possible valid number is returned |
| divideByZero | If true, a divide by zero will cause a CPDecimalNumberDivideByZeroException exception to be raised, else a NotANumber (NaN) CPDecimal is returned |
Definition at line 80 of file CPDecimalNumber.j.
| - (CPRoundingMode) roundingMode |
Returns the current rounding mode. One of CPRoundingMode enum: CPRoundPlain, CPRoundDown, CPRoundUp, CPRoundBankers.
Definition at line 134 of file CPDecimalNumber.j.
| - (short) scale |
Returns the number of digits allowed after the decimal point.
Definition at line 143 of file CPDecimalNumber.j.