@TypeInfo(value=DecimalTypeInfoFactory.class) public final class Decimal extends Object implements Comparable<Decimal>
The semantics of the fields are as follows: - precision and scale represent the SQL precision and scale we are looking for - If decimalVal is set, it represents the whole decimal value - Otherwise, the decimal value is longVal / (10 ** scale).
Modifier and Type | Field and Description |
---|---|
static DecimalType |
DECIMAL_SYSTEM_DEFAULT |
static int |
MAX_COMPACT_PRECISION |
static int |
MAX_INT_DIGITS
Maximum number of decimal digits an Int can represent.
|
static int |
MAX_LONG_DIGITS
Maximum number of decimal digits a Long can represent.
|
static long[] |
POW10 |
Modifier and Type | Method and Description |
---|---|
Decimal |
abs() |
static Decimal |
add(Decimal v1,
Decimal v2,
int precision,
int scale) |
static Decimal |
castFrom(boolean val,
int p,
int s) |
static Decimal |
castFrom(Decimal dec,
int precision,
int scale) |
static Decimal |
castFrom(double val,
int p,
int s) |
static Decimal |
castFrom(long val,
int p,
int s) |
static Decimal |
castFrom(String string,
int precision,
int scale) |
static boolean |
castToBoolean(Decimal dec) |
static byte |
castToByte(Decimal dec) |
static Decimal |
castToDecimal(Decimal dec,
int precision,
int scale) |
static double |
castToDouble(Decimal dec) |
static float |
castToFloat(Decimal dec) |
static int |
castToInt(Decimal dec) |
static long |
castToIntegral(Decimal dec) |
static long |
castToLong(Decimal dec) |
static short |
castToShort(Decimal dec) |
static long |
castToTimestamp(Decimal dec) |
Decimal |
ceil() |
static int |
compare(Decimal b1,
Decimal b2) |
static int |
compare(Decimal b1,
double n2) |
static int |
compare(Decimal b1,
long n2) |
static int |
compare(double n1,
Decimal b2) |
static int |
compare(long n1,
Decimal b2) |
int |
compareTo(Decimal that) |
Decimal |
copy() |
static Decimal |
divide(Decimal v1,
Decimal v2,
int precision,
int scale) |
static Decimal |
divideToIntegralValue(Decimal value,
Decimal divisor,
int precision,
int scale)
Returns a
Decimal whose value is the integer part
of the quotient (this / divisor) rounded down. |
double |
doubleValue() |
boolean |
equals(Object o) |
Decimal |
floor() |
static Decimal |
fromBigDecimal(BigDecimal bd,
int precision,
int scale) |
static Decimal |
fromLong(long l,
int precision,
int scale) |
static Decimal |
fromUnscaledBytes(int precision,
int scale,
byte[] bytes) |
static Decimal |
fromUnscaledLong(int precision,
int scale,
long longVal) |
int |
getPrecision() |
int |
getScale() |
int |
hashCode() |
static boolean |
is32BitDecimal(int precision) |
static boolean |
is64BitDecimal(int precision) |
static boolean |
isByteArrayDecimal(int precision) |
boolean |
isCompact() |
static boolean |
isCompact(int precision) |
static Decimal |
mod(Decimal v1,
Decimal v2,
int precision,
int scale) |
static Decimal |
multiply(Decimal v1,
Decimal v2,
int precision,
int scale) |
Decimal |
negate() |
static Decimal |
sign(Decimal b0)
SQL
SIGN operator applied to BigDecimal values. |
int |
signum()
Returns the signum function of this decimal.
|
static Decimal |
sround(Decimal b0,
int r)
SQL
ROUND operator applied to BigDecimal values. |
static Decimal |
subtract(Decimal v1,
Decimal v2,
int precision,
int scale) |
BigDecimal |
toBigDecimal() |
String |
toString() |
byte[] |
toUnscaledBytes() |
long |
toUnscaledLong() |
static Decimal |
zero(int precision,
int scale) |
public static final int MAX_COMPACT_PRECISION
public static final int MAX_INT_DIGITS
public static final int MAX_LONG_DIGITS
public static final long[] POW10
public static final DecimalType DECIMAL_SYSTEM_DEFAULT
public boolean isCompact()
public static boolean isCompact(int precision)
public BigDecimal toBigDecimal()
public int compareTo(Decimal that)
compareTo
in interface Comparable<Decimal>
public int signum()
public static Decimal fromLong(long l, int precision, int scale)
public static Decimal fromBigDecimal(BigDecimal bd, int precision, int scale)
public static Decimal zero(int precision, int scale)
public Decimal copy()
public long toUnscaledLong()
public static Decimal fromUnscaledLong(int precision, int scale, long longVal)
public byte[] toUnscaledBytes()
public static Decimal fromUnscaledBytes(int precision, int scale, byte[] bytes)
public double doubleValue()
public Decimal negate()
public Decimal abs()
public Decimal floor()
public Decimal ceil()
public int getPrecision()
public int getScale()
public static Decimal divideToIntegralValue(Decimal value, Decimal divisor, int precision, int scale)
Decimal
whose value is the integer part
of the quotient (this / divisor)
rounded down.value
- value by which this Decimal
is to be divided.divisor
- value by which this Decimal
is to be divided.this / divisor
.ArithmeticException
- if divisor==0
public static long castToIntegral(Decimal dec)
public static long castToLong(Decimal dec)
public static int castToInt(Decimal dec)
public static short castToShort(Decimal dec)
public static byte castToByte(Decimal dec)
public static float castToFloat(Decimal dec)
public static double castToDouble(Decimal dec)
public static boolean castToBoolean(Decimal dec)
public static long castToTimestamp(Decimal dec)
public static Decimal castFrom(double val, int p, int s)
public static Decimal castFrom(long val, int p, int s)
public static Decimal castFrom(boolean val, int p, int s)
public static Decimal sign(Decimal b0)
SIGN
operator applied to BigDecimal values.
preserve precision and scale.public static int compare(Decimal b1, long n2)
public static int compare(Decimal b1, double n2)
public static int compare(long n1, Decimal b2)
public static int compare(double n1, Decimal b2)
public static Decimal sround(Decimal b0, int r)
ROUND
operator applied to BigDecimal values.public static boolean is32BitDecimal(int precision)
public static boolean is64BitDecimal(int precision)
public static boolean isByteArrayDecimal(int precision)
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.