public class decimal extends NumberType
unknown value
representation and the core comparison logic.
All Progress language features related to integer/decimal data
types are implemented in the MathOps
class (except comparison
logic which is in CompareOps
. All Progress integer/decimal
features are supported including all functionality that can be accessed
via operators and built-in Progress functions.
Rounding and truncation behavior is completely implemented in this class. In particular, assignments do cause a rounding (thus a potential loss of precision) but constructors (the equivalent of the Progress "init" keyword) do not round even when the precision is set lower than the number of significant digits to the right of the decimal point. This is how it is done in Progress.
An interesting point: intermediate decimal outputs from functions and
operators do not inherit the precision (DECIMALS
) of the
operands or parameters. In other words, all returned instances from
operators or functions will have the default precision of 10.
Modifier and Type | Class and Description |
---|---|
private static class |
decimal.ContextContainer
Simple container that stores and returns a context-local instance of
the global work area.
|
private class |
decimal.PrecisionResetter
Helper to reset the associated instance's precision to a prior value
based on a notification that a particular scope has exited.
|
private static class |
decimal.WorkArea
Stores global data relating to the state of the current context.
|
NumberType.FormatSpec
Modifier and Type | Field and Description |
---|---|
static int |
MAX_SCALE
Maximum precision scale applied to any decimal instance
|
(package private) static java.math.BigDecimal |
ONE
Constant for BigDecimal value 1 with scale MAX_SCALE
|
private int |
scale
The number of digits to preserve and to limit to the right of the
decimal point.
|
private java.math.BigDecimal |
value
Stores the value of this instance.
|
private static decimal.ContextContainer |
work
Stores context-local state variables.
|
(package private) static java.math.BigDecimal |
ZERO
Constant for BigDecimal value 0 with scale MAX_SCALE
|
FORMAT_DEC_SEP, FORMAT_GROUP_SEP, SIGN_CR, SIGN_DB, SIGN_DR, SIGN_LEFT_MINUS, SIGN_LEFT_PLUS, SIGN_NONE, SIGN_PAREN, SIGN_PAREN_EMBED, SIGN_RIGHT_MINUS, SIGN_RIGHT_PLUS
Constructor and Description |
---|
decimal()
Default constructor which creates an instance representing the
unknown value . |
decimal(BaseDataType value)
This is a special c'tor which should be used only when converting the
value returned by a function or method with polymorphic return type into the
expected type (i.e.
|
decimal(boolean value)
Constructs an instance after copying the parameter's data into the
internal representation of this class.
|
decimal(character value)
Constructs an instance after converting the string representation of a number into a
BigDecimal . |
decimal(date value)
Constructs an instance after copying the parameter's data into the
internal representation of this class.
|
decimal(decimal value)
Constructs an instance after copying the parameter into the internal
representation of this class.
|
decimal(double value)
Constructs an instance from a double value and with precision set to
its maximum.
|
decimal(double value,
int precision)
Constructs an instance from a double value.
|
decimal(int value)
Constructs an instance from an int value and with precision set to its
maximum.
|
decimal(int64 value)
Constructs an instance from an int64 value and with precision set to
its maximum.
|
decimal(integer value)
Constructs an instance from an integer value and with precision set to
its maximum.
|
decimal(int value,
int precision)
Constructs an instance from an int value.
|
decimal(logical value)
Constructs an instance after copying the parameter's data into the
internal representation of this class.
|
decimal(long value)
Constructs an instance from a long value and with precision set to its
maximum.
|
decimal(java.lang.Number value)
Constructs an instance after copying the parameter's data into the
internal representation of this class.
|
decimal(java.lang.String value)
Constructs an instance after converting the string representation of a number into a
BigDecimal . |
decimal(java.lang.String value,
int precision)
Constructs an instance after converting the string representation of a number into a
BigDecimal . |
Modifier and Type | Method and Description |
---|---|
void |
assign(BaseDataType value,
boolean force)
Sets the state (data and unknown value) of this instance based on the
state of the passed instance.
|
void |
assign(double value)
Sets the state (data/unknown value) of this instance based on the state
of the passed data.
|
void |
assign(int value)
Sets the state (data) of this instance based on the input data.
|
void |
assign(NumberType value)
Sets the state (data/unknown value) of this instance based on the state
of the passed instance.
|
void |
assign(NumberType value,
boolean force)
Sets the state (data and unknown value) of this instance based on the
state of the passed instance.
|
void |
assign(Undoable value)
Sets the state (data and unknown value) of this instance based on the
state of the passed instance.
|
java.lang.String |
buildDefaultFormat()
Dynamically builds the default format string for this given number type
which honors the given group and decimal separators.
|
java.lang.String |
buildExportFormat()
Returns the export format string for this given number type which
honors the given group and decimal separators.
|
int |
compareTo(java.lang.Object obj)
Compares this instance with the specified instance and returns a -1
if this instance is less than the specified, 0 if the two instances
are equal and 1 if this instance is greater than the specified
instance.
|
void |
decrement()
Decrements the value of this instance by 1.
|
void |
deepAssign(NumberType value)
Sets the state (data/unknown value) and configuration (precision) of
this instance based on the state of the passed instance.
|
double |
doubleValue()
Returns the value of this instance as a
double . |
BaseDataType |
duplicate()
Does the same as standard
clone() method but returns an
instance of BaseDataType and doesn't throw the
CloneNotSupportedException . |
boolean |
equals(java.lang.Object o)
An equality test which handles the most common cases with the least
amount of overhead.
|
static decimal |
fromLiteral(java.lang.String decimalLiteral)
Parses a Progress decimal literal and returns a
decimal represented. |
integer |
getBitsWorker(double pos,
double len)
Worker method for getBits, this returns the number of bits from the
given position as an
integer . |
private static java.text.DecimalFormat |
getDecimalFormat()
Get the decimal format, which uses the custom group and decimal separators.
|
int |
getPrecision()
Returns the number of digits that will be maintained to the right of
the decimal point in this instance.
|
(package private) double |
getValue()
Returns the value of this instance as a
double . |
int |
hashCode()
Hash code implementation which is consistent with
BaseDataType.equals(java.lang.Object) . |
void |
increment()
Increments the value of this instance by 1.
|
BaseDataType |
instantiateDefault()
Creates a new instance of the same type that represents the
default initialized value.
|
protected BaseDataType |
instantiateDefaultExtent()
Get the default initialization for an extent variable of this type.
|
BaseDataType |
instantiateUnknown()
Creates a new instance of the same type that represents the
unknown value . |
integer |
integerValue()
Returns the value of this instance as an
integer . |
int |
intValue()
Returns the value of this instance as an
int . |
boolean |
isOverflow(java.math.BigDecimal bd,
boolean normal,
boolean raise)
Test if the given input would cause an overflow error in the 4GL and raise that
error if needed.
|
boolean |
isUnknown()
Determines if this instance represents the
unknown value . |
long |
longValue()
Returns the value of this instance as a
long . |
static void |
main(java.lang.String[] args)
Simple command line harness to test the toString() method.
|
decimal |
maximum(decimal d)
Returns the larger of the current or passed-in instance.
|
static decimal |
maximum(NumberType... list)
Returns the largest instance from the list.
|
decimal |
minimum(decimal d)
Returns the smaller of the current or passed-in instance.
|
static decimal |
minimum(NumberType... list)
Returns the smallest instance from the list.
|
java.lang.String |
obtainDefaultFormat()
Returns the default format string for this given number type (which
honors the given group and decimal separators), building that format
and caching it if this is the first call in this context.
|
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
(package private) static void |
removeExplicitFormats()
Clear any cached formats using the custom group and decimal separators.
|
void |
setBitsWorker(double data,
double pos,
double len)
Worker method for setBits, this copies the bit representation of an
integer to a location with a given number of bits within the current integer variable.
|
static void |
setPrecision(decimal[] list,
int precision)
Sets the number of digits that will be maintained to the right of
the decimal point in each element of the given array.
|
void |
setPrecision(int precision)
Sets the number of digits that will be maintained to the right of
the decimal point in this instance.
|
void |
setTemporaryPrecision(int precision)
Sets the number of digits that will be maintained to the right of
the decimal point in this instance, for the durations of the current
scope in the calling program.
|
void |
setUnknown()
Sets the state of this instance's
unknown value state. |
private void |
setValue(java.math.BigDecimal value)
Set the value of this instance from the given numeric value.
|
private void |
setValue(double value)
Set the value of this instance as a
double . |
private void |
setValue(java.lang.String value)
Set the value of this instance from a Progress-formatted string.
|
java.math.BigDecimal |
toBigDecimal()
Returns the value of this instance as a
BigDecimal . |
java.math.BigDecimal |
toJavaType()
Return the current value as a Java wrapper.
|
java.lang.String |
toString()
Creates a string representation of the instance data using the default
Progress 4GL format of '->>,>>9.99'.
|
java.lang.String |
toString(java.lang.String fmt)
Creates a string representation of the instance data using the user
specified format string (Progress 4GL compatible) or if no such
string is provided, the default format of '->>,>>9.99'.
|
java.lang.String |
toString(java.lang.String fmt,
boolean rightAlign)
Creates a string representation of the instance data using the user
specified format string (Progress 4GL compatible) or if no such
string is provided, the default format of '->>,>>9.99'.
|
java.lang.String |
toString(java.lang.String fmt,
boolean rightAlign,
boolean forceNegative)
Creates a string representation of the instance data using the user
specified format string (Progress 4GL compatible) or if no such
string is provided, the default format of '->>,>>9.99'.
|
java.lang.String |
toStringExport()
Creates a string representation of the instance data using the 'export'
format.
|
java.lang.String |
toStringMessage()
Creates a string representation of the instance data in a form that is
compatible with the
MESSAGE language statement. |
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
defaultFormatString, generateSimpleFormat, getBits, getBits, getBits, getBits, getDecimalSeparator, getDecimalSeparatorIndex, getDefaultFormat, getDigitsLeft, getDigitsRight, getEmbedIndex, getExportFormat, getGroupSeparator, getNumericDecimalPoint, getNumericFormat, getNumericSeparator, getNumGroupSeparators, getUserLeft, getUserRight, getValueTextLength, isDigitChar, isFormatChar, overrideDefaultSeparators, parseDecimal, parseDecimal, parseDouble, parseDouble, parseFormat, setBits, setBits, setBits, setBits, setBits, setBits, setBits, setNumericFormat, setNumericFormat, setNumericFormat, setNumericFormat, setNumericFormat, setNumericFormat, setNumericFormat, subscript, toString, toString
assign, calcFormatLength, deepCopy, elementsOfType, formatLength, generateDefault, generateUnknown, getTypeName, incompatibleTypesOnConversion, initializeDefaultExtent, isUnknownValue, maximum, minimum, notUnknownValue, sameType
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobal
public static final int MAX_SCALE
static final java.math.BigDecimal ZERO
static final java.math.BigDecimal ONE
private static decimal.ContextContainer work
private java.math.BigDecimal value
null
represents the
unknown value
.private int scale
value
to preserve scale when wrapper is set to unknown
value
.public decimal()
unknown value
.public decimal(BaseDataType value)
assign(BaseDataType,boolean)
).value
- The value to be used for this instance.public decimal(long value)
It is not possible to yield an unknown value
from this
constructor without calling the method setUnknown()
separately.
value
- The value to be used for this instance.public decimal(int value)
It is not possible to yield an unknown value
from this
constructor without calling the method setUnknown()
separately.
value
- The value to be used for this instance.public decimal(int value, int precision)
It is not possible to yield an unknown value
from this
constructor without calling the method setUnknown()
separately.
value
- The value to be used for this instance.precision
- The number of digits to maintain to the right of the decimal
point.public decimal(integer value)
If the parameter's represents the unknown value
, this
instance will also represent the unknown value
.
value
- The value to be used for this instance.public decimal(int64 value)
If the parameter's represents the unknown value
, this
instance will also represent the unknown value
.
value
- The value to be used for this instance.public decimal(double value)
If the parameter's value is NaN
, the instance will
represent the unknown value
.
value
- The value to be used for this instance.public decimal(double value, int precision)
If the parameter's value is NaN
, the instance will
represent the unknown value
.
value
- The value to be used for this instance.precision
- The number of digits to maintain to the right of the decimal
point.public decimal(decimal value)
If the parameter's represents the unknown value
, this
instance will also represent the unknown value
.
value
- The value to be used for this instance.public decimal(java.lang.String value)
BigDecimal
. Due to rounding, a loss of precision may occur in this conversion (at
the 10th digit to the right of the decimal point).
This conversion constructor always uses the current number format for parsing. Ex: in the
default (American) format "3,141" parses as an integer value of 3141, but on European
(-E Progress command line parameter) it will be parsed as an approximation of PI (3.141).
For parsing a decimal literal (in American format) regardless of current number format use
the fromLiteral(String)
.
value
- The value to be used for this instance.public decimal(java.lang.String value, int precision)
BigDecimal
. Due to rounding, a loss of precision may occur in this conversion.
This conversion constructor always uses the current number format for parsing. Ex: in the
default (American) format "3,141" parses as an integer value of 3141, but on European
(-E Progress command line parameter) it will be parsed as an approximation of PI (3.141).
For parsing a decimal literal (in American format) regardless of current number format use
the fromLiteral(String)
.
value
- The value to be used for this instance.precision
- The number of digits to maintain to the right of the decimal
point.public decimal(character value)
BigDecimal
. Due to rounding, a loss of precision may occur in this conversion (at
the 10th digit to the right of the decimal point).
This conversion constructor always uses the current number format for parsing. Ex: in the
default (American) format "3,141" parses as an integer value of 3141, but on European
(-E Progress command line parameter) it will be parsed as an approximation of PI (3.141).
For parsing a decimal literal (in American format) regardless of current number format use
the fromLiteral(String)
.
If the parameter is unknown value
the resulting decimal is the unknown
value
.
value
- The value to be used for this instance.public decimal(logical value)
If the parameter's represents the unknown value
, this
instance will also represent the unknown value
.
When the parameter is true
the resulting decimal value
will be 1. Otherwise the value is 0.
value
- The value to be used for this instance.public decimal(boolean value)
When the parameter is true
the resulting decimal value
will be 1. Otherwise the value is 0.
value
- The value to be used for this instance.public decimal(date value)
If the parameter represents the unknown value
, this
instance will also represent the unknown value
.
value
- The value to be used for this instance.public decimal(java.lang.Number value)
If the parameter is null
, this instance will represent
the unknown value
.
value
- The value to be used for this instance.public static decimal fromLiteral(java.lang.String decimalLiteral)
decimal
represented.
Unlike the conversion constructors that always uses the current number format for parsing,
this utility method will always use the American number format, regardless of current number
format in use. If you need to convert a language dependent string, use one of the conversion
constructors.
Ex: the "3,141" will always be parsed as a decimal with integer value of 3141. The same string will be parsed by the conversion constructors as 3141 if the default (American) number format is in use or as an approximation of PI (3.141) if the European (-E Progress command line parameter) format was set.
decimalLiteral
- The string to be parsed.decimalLiteral
.public static decimal maximum(NumberType... list)
null
values.list
- The list of decimals and/or integers to check.unknown value
if any entries in the list are
unknown
or null
if an empty list is passed.public static decimal minimum(NumberType... list)
null
values.list
- The list of decimals and/or integers to check.unknown value
if any
entries in the list are unknown or null
if
an empty list is passed.public static void setPrecision(decimal[] list, int precision)
The precision will become effective on the next value assignment. I.e. the value will not change its precision right after this method is called.
precision
- The precision which must range between 0 and 10 (inclusive).static void removeExplicitFormats()
private static java.text.DecimalFormat getDecimalFormat()
public java.lang.String buildDefaultFormat()
buildDefaultFormat
in class NumberType
public java.lang.String obtainDefaultFormat()
obtainDefaultFormat
in class NumberType
public java.lang.String buildExportFormat()
buildExportFormat
in class NumberType
null
if this type does not use an export
format.public boolean equals(java.lang.Object o)
This implementation is consistent with hashCode()
.
equals
in class BaseDataType
o
- The instance to compare against.true
if the objects compare equivalently; false
if they do not,
or if the parameter is not a BaseDataType
instance.BaseDataType.equals(java.lang.Object)
public int hashCode()
BaseDataType.equals(java.lang.Object)
.hashCode
in class BaseDataType
public long longValue() throws java.lang.NullPointerException
long
. Loss of
precision may occur in this conversion (all digits to the right of
the decimal point will be truncated).
This method will fail if the instance represents the
unknown value
.
longValue
in class NumberType
long
.java.lang.NullPointerException
- If this instance represents the unknown value
.public int intValue() throws java.lang.NullPointerException, ErrorConditionException
int
. Loss of
precision may occur in this conversion. All digits to the right of
the decimal point will be truncated and some large numbers cannot be
represented in an int
.
This method will fail if the instance represents the
unknown value
.
intValue
in class NumberType
int
.java.lang.NullPointerException
- If this instance represents the unknown value
.ErrorConditionException
- If the value is too large to fit in an integer.public integer integerValue()
integer
. Loss of
precision may occur in this conversion. All digits to the right of
the decimal point will be truncated and some large numbers cannot be
represented in an integer
.
This method will maintain the unknown value
in the
returned instance if this instance represents the
unknown value
.
integer
.public double doubleValue()
double
. Loss
of precision may occur in this conversion, if the current value cannot
be represented in a double
. This is the same as getValue()
. Use toBigDecimal() if keeping the precision
is the concern.
If this instance represents the unknown value
, the
returned double
will be set to NaN
.
doubleValue
in class NumberType
public java.math.BigDecimal toBigDecimal()
BigDecimal
. No loss
of precision will occur in this conversion.
If this instance represents the unknown value
, the
return value will be null
.
toBigDecimal
in class NumberType
BigDecimal
instance, see above for details.public void increment()
If this instance represents the unknown value
, nothing
is done.
increment
in class NumberType
public void decrement()
If this instance represents the unknown value
, nothing
is done.
decrement
in class NumberType
public boolean isUnknown()
unknown value
.isUnknown
in class BaseDataType
true
if this instance is set to the
unknown value
.public void setUnknown()
unknown value
state.
Warning: this method is destructive. Any data previously stored instance is set to the correct value.
setUnknown
in class BaseDataType
public BaseDataType instantiateUnknown()
unknown value
.instantiateUnknown
in class BaseDataType
unknown value
.public BaseDataType instantiateDefault()
instantiateDefault
in class BaseDataType
public BaseDataType duplicate()
clone()
method but returns an
instance of BaseDataType
and doesn't throw the
CloneNotSupportedException
.duplicate
in class BaseDataType
public void assign(BaseDataType value, boolean force)
If the value is not of type NumberType
, the following automatic type
conversion will occur:
This variant is meant to handle the cases of built-in functions and methods in the 4GL which have polymorphic return types (e.g. DYNAMIC-FUNCTION()). This should NOT be used for non-polymorphic assignments.
assign
in class BaseDataType
value
- The instance from which to copy state.force
- Flag to indicate if a pending error should be ignored (see
ErrorManager.isPendingError()
and the assignment
forced regardless. Note that normal assignment silently
exits with no change if there is a pending error. If this
flag is true
, that check is bypassed and the
assignment will always be done.public void assign(NumberType value, boolean force)
value
- The instance from which to copy state.force
- Flag to indicate if a pending error should be ignored (see
ErrorManager.isPendingError()
and the assignment
forced regardless. Note that normal assignment silently
exits with no change if there is a pending error. If this
flag is true
, that check is bypassed and the
assignment will always be done.public void assign(double value)
deepAssign(com.goldencode.p2j.util.NumberType)
if both state and
configuration must be set.
This method may result in a loss of precision if the number of
significant digits to the right of the decimal point is greater than
that specified by the precision
instance member. In this
case, the excess digits will be dropped using a rounding method (if
the leftmost lost digit is 0-4 it will round down and 5-9 it will round
up).
This is a "no operation" in the case where silent error mode is active
AND an error has occurred in the current processing since the opening
call to ErrorManager.silentErrorEnable()
. This protection is
needed to ensure that the state of this instance does not change in
this case. This will not affect undo because that only occurs when
silent error mode is disabled.
value
- The data from which to copy state. NaN
will
force this instance to be the unknown value.public void assign(int value)
deepAssign(com.goldencode.p2j.util.NumberType)
if both state and configuration must be set.
This is a "no operation" in the case where silent error mode is active
AND an error has occurred in the current processing since the opening
call to ErrorManager.silentErrorEnable()
. This protection is
needed to ensure that the state of this instance does not change in
this case. This will not affect undo because that only occurs when
silent error mode is disabled.
value
- The data from which to copy state.public void assign(NumberType value)
deepAssign(com.goldencode.p2j.util.NumberType)
if both state and
configuration must be set.
This method may result in a loss of precision if the number of
significant digits to the right of the decimal point is greater than
that specified by the precision
instance member. In this
case, the excess digits will be dropped using a rounding method (if
the leftmost lost digit is 0-4 it will round down and 5-9 it will round
up).
This is a "no operation" in the case where silent error mode is active
AND an error has occurred in the current processing since the opening
call to ErrorManager.silentErrorEnable()
. This protection is
needed to ensure that the state of this instance does not change in
this case. This will not affect undo because that only occurs when
silent error mode is disabled.
value
- The instance from which to copy state.public void assign(Undoable value)
value
- The instance from which to copy state.public void deepAssign(NumberType value)
value
- The instance from which to copy state.public int getPrecision()
public void setPrecision(int precision)
This method is used to set the current value in a manner that does not
schedule an automated reset to the prior value later. Thus, this method
is suitable for the initial configuration of a new instance. If a
temporary precision change is needed, use
setTemporaryPrecision(int)
.
The precision will become effective on the next value assignment. I.e. the value will not change its precision right after this method is called.
precision
- The precision for this instance which must range between 0
and 10 (inclusive).public void setTemporaryPrecision(int precision)
This method should only be used when importing references via the
SharedVariableManager
as a local instance or a new shared
instance would not need to be reset, since they would have no prior
value to which to return. To set the initial precision, please use
setPrecision(com.goldencode.p2j.util.decimal[], int)
.
The TransactionManager.registerFinalizable(com.goldencode.p2j.util.Finalizable, boolean)
facility is used to
obtain the callback necessary to reset the precision at end of the
caller's scope.
The precision will become effective on the next value assignment. I.e. the value will not change its precision right after this method is called.
precision
- The precision for this instance which must range between 0
and 10 (inclusive).public int compareTo(java.lang.Object obj)
Comparable
interface.
The algorithm will fail to give meaningful results in the case where one tries to sort against other objects that do not represent compatible values.
obj
- The instance to compare against.obj
.public decimal maximum(decimal d)
d
- The instance to compare against.public decimal minimum(decimal d)
d
- The instance to compare against.public java.math.BigDecimal toJavaType()
null
if unknown.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringMessage()
MESSAGE
language statement. If the
instance represents the unknown value
, a '?' will be
returned.toStringMessage
in class BaseDataType
public java.lang.String toStringExport()
toStringExport
in class BaseDataType
public java.lang.String toString(java.lang.String fmt)
toString
in class BaseDataType
fmt
- The Progress 4GL format string or null
if the
default format is to be used.public java.lang.String toString(java.lang.String fmt, boolean rightAlign)
fmt
- The Progress 4GL format string or null
if the
default format is to be used.rightAlign
- Pad on the left to the full size of the format string if the
format has '>' characters that match the positions of
leading zeroes.public java.lang.String toString(java.lang.String fmt, boolean rightAlign, boolean forceNegative)
fmt
- The Progress 4GL format string or null
if the
default format is to be used.rightAlign
- Pad on the left to the full size of the format string if the
format has '>' characters that match the positions of
leading zeroes.forceNegative
- Flag indicating the forcing including the negative sign value
in the case when the real value is 0.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- The input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public void setBitsWorker(double data, double pos, double len)
setBitsWorker
in class NumberType
data
- The bit representation of an integer to be copied.pos
- The 1-based index position to set, must be > 0.len
- The number of bytes to take into consideration when performing the operation.public integer getBitsWorker(double pos, double len)
integer
.getBitsWorker
in class NumberType
pos
- The 1-based index position to set, must be > 0.len
- The number of bits to take into consideration when performing the operation.integer
.public boolean isOverflow(java.math.BigDecimal bd, boolean normal, boolean raise)
bd
- The input to test. It should already have been scaled to the target level.normal
- true
if all trailing zeroes have been removed already.raise
- true
if the error should be raised, false
to
bypass error generation and simply just return the calculated result.true
if an overflow would occur (the return in this case won't
be seen unless silent error mode is on). false
otherwise.double getValue()
double
. Loss
of precision may occur in this conversion, if the current value cannot
be represented in a double
. This is the same as doubleValue()
.
If this instance represents the unknown value
, the
returned double
will be set to NaN
.
double
.protected BaseDataType instantiateDefaultExtent()
instantiateDefaultExtent
in class BaseDataType
private void setValue(java.math.BigDecimal value)
If the passed-in value is null
, the instance will
represent the unknown value
. If this instance previously
represented the unknown value
and null
is not
passed, the unknown value
state will be
false
.
value
- The value to be represented in this instance.private void setValue(java.lang.String value)
scale
instance member of this object. The resulting value will be rounded
to the proper number of digits.
If the passed-in value is null
, the instance will
represent the unknown value
. If this instance previously
represented the unknown value
and null
is not
passed, the unknown value
state will be
false
.
value
- The value to be represented in this instance.private void setValue(double value)
double
. A loss
of precision will occur in this conversion if the passed value has
more significant digits than the setting of the precision
instance member of this object. The resulting value will be rounded
to the proper number of digits.
If the passed-in value is NaN
or infinity (positive or negative), the
instance will represent 0, which is how the 4GL deals with these values when reading
them directly from memory (e.g. when passed back via a native API call). Actually
with infinity, the 4GL goes into an infinite loop and needs to be hard-killed, but
this code won't duplicate that "feature".
value
- The value to be represented in this instance.public static void main(java.lang.String[] args)
args
- 1. numeric value
2. format string