public enum NumericPrecision extends Enum<NumericPrecision>
size
of the implementing vector (bit
count). Generally, "known" implies that it is more precise to know
that zero digits are available than to not know at all which in turn implies
that UNKNOWN
is less precise than NULL
which is a
known precision (vector size of zero). Unlimited
numbers however do not have known digit counts at design time but definitely
have known digit counts at runtime so are said to be of higher precision than
UNKNOWN
and are, in fact, the highest since their possible
digit counts are known to be for all practical purposes unlimited.Enum Constant and Description |
---|
BIT
Boolean domain which includes
0 and 1 (field
cardinality is 2) |
BYTE
Byte field, or 8 bits, for a total value count (field cardinality)
of 28 and a signed value range of -27 to 27-1
|
CHARACTER
Unsigned character field with the same bit count as
SHORT
, so it shares both its cardinality (216) and precision,
though its unsigned value range is 0 to 216-1 |
DOUBLE
IEEE 754-2008
single precision
float value (32 bits). |
FLOAT
IEEE 754-2008
single precision
float value (32 bits). |
INTEGER
Integer field, or 4 bytes (32 bits), for a total value count
(field cardinality) of 232 and a value range of -231 to 231-1
|
LONG
Integer field, or 8 bytes (64 bits), for a total value count
(field cardinality) of 264 and a value range of -263 to 263-1
|
NULL
No numeric domain, or the empty set (no digits, not even
0
, though its field cardinality is 0) |
SHORT
Short field, or two
bytes , for a total value count
(field cardinality) of 216 and a signed value range of
-215 to 215-1 |
UNKNOWN
Unknown precision, which is even less precise than
NULL
(empty set) |
UNLIMITED_DECIMAL
Unlimited decimal value of arbitrary precision and the highest
precision of any specifiable value
|
UNLIMITED_INTEGER
Unlimited integer value of arbitrary precision, which is only less
precise than the unlimited
decimal precision |
Modifier and Type | Field and Description |
---|---|
static NumericPrecision |
MAXIMUM |
static NumericPrecision |
MINIMUM |
Modifier and Type | Method and Description |
---|---|
abstract int |
compare(NumericPrecision prec)
Primitive1 this precision against
another. |
Class<?> |
getNumberClass() |
static NumericPrecision |
getPrecisionFor(Class<?> aClass) |
static NumericPrecision |
getPrecisionFor(Object aValue) |
Class<?> |
getPrimitiveClass() |
abstract boolean |
isEquallyPreciseAs(NumericPrecision prec) |
abstract boolean |
isFinite() |
abstract boolean |
isFloatingPoint() |
abstract boolean |
isIeee754() |
abstract boolean |
isIntegral() |
boolean |
isLessOrEquallyPreciseAs(NumericPrecision prec) |
abstract boolean |
isLessPreciseThan(NumericPrecision prec) |
boolean |
isMoreOrEquallyPreciseAs(NumericPrecision prec) |
abstract boolean |
isMorePreciseThan(NumericPrecision prec) |
abstract boolean |
isNumeric() |
abstract boolean |
isSigned() |
abstract boolean |
isUnlimited() |
NumericPrecision |
maximumOf(NumericPrecision prec) |
NumericPrecision |
maximumOfAll(NumericPrecision... precisions) |
abstract NumericPrecision |
promote() |
abstract NumericPrecision |
promoteAgainst(NumericPrecision prec)
Answer a precision value such that any mathematical operation between
values of this precision and those of the specified one will not result
in a loss of information.
|
abstract int |
size() |
abstract NumericPrecision |
toFloatingPoint() |
static NumericPrecision |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static NumericPrecision[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final NumericPrecision UNKNOWN
NULL
(empty set)public static final NumericPrecision NULL
0
, though its field cardinality is 0)public static final NumericPrecision BIT
0
and 1
(field
cardinality is 2)public static final NumericPrecision BYTE
public static final NumericPrecision SHORT
bytes
, for a total value count
(field cardinality) of 216 and a signed value range of
-215 to 215-1public static final NumericPrecision CHARACTER
SHORT
, so it shares both its cardinality (216) and precision,
though its unsigned value range is 0 to 216-1public static final NumericPrecision INTEGER
public static final NumericPrecision LONG
public static final NumericPrecision FLOAT
float
value (32 bits). Though, strictly
speaking, the value field size is actually smaller than that of a 32 bit
integer
due to the float
's 23 bit significand size,
float
is treated as a more precise value because of its
significantly increased minimum-to-maximum value range.public static final NumericPrecision DOUBLE
float
value (32 bits). Though, strictly
speaking, the value field size is actually smaller than that of a 64 bit
long
due to the double
's 53 bit significand size,
double
is treated as a more precise value because of its
significantly increased minimum-to-maximum value range.public static final NumericPrecision UNLIMITED_INTEGER
decimal
precisionpublic static final NumericPrecision UNLIMITED_DECIMAL
public static NumericPrecision MAXIMUM
public static NumericPrecision MINIMUM
public static NumericPrecision[] values()
for (NumericPrecision c : NumericPrecision.values()) System.out.println(c);
public static NumericPrecision valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant
with the specified nameNullPointerException
- if the argument is nullpublic abstract int compare(NumericPrecision prec)
Primitive1
this precision against
another. This method is included, and named what it is because
Enum
implements compareTo
to simply compare the
ordinal
values of any two compatible enumerations.prec
- another precisionComparable.compareTo(Object)
public final Class<?> getNumberClass()
public final Class<?> getPrimitiveClass()
public abstract boolean isEquallyPreciseAs(NumericPrecision prec)
prec
- another precision enumerationtrue
if this precision is as precise as the specified
precisionpublic abstract boolean isFinite()
true
if this precision is known and finitepublic abstract boolean isFloatingPoint()
true
if this precision represents a floating point valuepublic abstract boolean isIeee754()
true
if this precision represents an IEEE 754 floating
point valuepublic abstract boolean isIntegral()
true
if this precision represents an integral (no decimal
point) valuepublic final boolean isLessOrEquallyPreciseAs(NumericPrecision prec)
prec
- another precision enumerationtrue
if this precision is less precise or as equally
precise as the specified precisionpublic abstract boolean isLessPreciseThan(NumericPrecision prec)
prec
- another precision enumerationtrue
if this precision is less precise than the specified
precisionpublic final boolean isMoreOrEquallyPreciseAs(NumericPrecision prec)
prec
- another precision enumerationtrue
if this precision is more precise or as equally
precise as the specified precisionpublic abstract boolean isMorePreciseThan(NumericPrecision prec)
prec
- another precision enumerationtrue
if this precision is more precise than the specified
precisionpublic abstract boolean isNumeric()
true
if this is a valid numeric precisionpublic abstract boolean isSigned()
true
if this precision is known and signedpublic abstract boolean isUnlimited()
true
if objects with this precision are implemented using
unlimited precision (e.g., BigInteger
or
BigDecimal
)public final NumericPrecision maximumOf(NumericPrecision prec)
public final NumericPrecision maximumOfAll(NumericPrecision... precisions)
public abstract NumericPrecision promote()
public abstract NumericPrecision promoteAgainst(NumericPrecision prec)
DOUBLE
unless precisions smaller than LONG
are explicitly promoted
against FLOAT
. Integral
numbers are always
promoted to floating points (rational real numbers when compared against
them. The unlimited
precision types (e.g.,
BigInteger
and BigDecimal
) will always force a promotion
to themselves.prec
- a precision to test againstpublic abstract int size()
public abstract NumericPrecision toFloatingPoint()
public static final NumericPrecision getPrecisionFor(Class<?> aClass)
public static final NumericPrecision getPrecisionFor(Object aValue)
Copyright © 2006-2012 Ware-Squared Software Development. All Rights Reserved.