Want more information ?. Try the Web Home Page for this document.
PSPDec supports decimal numeric fields of fixed-length. Within this fixed-length, PSPDec maintains an exact numeric value. The opposite of this is floating-point, where complex technical standards and 'degrees of precision' apply to numeric values. Our view is simple - floating point is for scientists, exact decimal numerics are for business. Read here why floating-point is inherently unsafe for business data processing.
PSPDec requires you to specify the number of digits you want either side
of the decimal place via the DigitsBeforeDP and DigitsAfterDP properties. Both these have a
maximum value of 50. PSPDec ensures you always have at least one digit i.e. it
is impossible to have both DigitsBeforeDP and DigitsAfterDP exactly zero.
When each PSPDec is first created, you get an opportunity to specify the
number of digits you require via the PSPDec constructor. After each PSPDec is
initialised, you can revise the size using the setDigitsBeforeDP(int) and setDigitsAfterDP(int) methods. For
example you may have a multi-currency application where you want to change an
initial setting of 2 decimal places to 0 decimal places if the run-time value
is for a currency with no fractions (e.g. Japanese Yen, Italian Lira).
Arithmetic operations may attempt to assign a new value to a PSPDec with more digits either side of the decimal place than the PSPDec itself. PSPDec overflow and rounding determines what happens.
When you change either DigitsBeforeDP or DigitsAfterDP, PSPDec creates an internal
number with the new size then assigns the current value of the PSPDec with the
old size to it. The normal rules for overflow
apply in this case if you reduce the number of digits before the decimal place.
If you reduce the number of digits after the decimal place, you control whether
the new value is rounded or not by your choice
of the setDigitsAfterDP(int) or setDigitsAfterDPRound(int) methods.
There is something else to note about arithmetic operations for
PSPDec's. They may involve different DigitsBeforeDP and/or DigitsAfterDP values. For
example, A and B in A.multiply(B) may have a different number of decimal
places. PSPDec ensures the results are arithmetically correct because our
internal routines use intermediate values large enough for arithmetic accuracy
(a sufficiently high number of digits either side of the decimal place).