Package org.apache.derby.client.am
Class Decimal
- java.lang.Object
-
- org.apache.derby.client.am.Decimal
-
public class Decimal extends java.lang.Object
Converters from fixed point decimal bytes tojava.math.BigDecimal
,double
, orlong
.
-
-
Field Summary
Fields Modifier and Type Field Description private static MessageUtil
msgutil
static int
PACKED_DECIMAL
Packed Decimal representationprivate static int[][]
tenRadixMagnitude
-
Constructor Summary
Constructors Modifier Constructor Description private
Decimal()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
bigDecimalToPackedDecimalBytes(byte[] buffer, int offset, java.math.BigDecimal b, int declaredPrecision, int declaredScale)
Write a Javajava.math.BigDecimal
to packed decimal bytes.private static int[]
computeMagnitude(int[] input)
Compute the int array of magnitude from input value segments.(package private) static java.math.BigDecimal
getBigDecimal(byte[] buffer, int offset, int precision, int scale)
Build ajava.math.BigDecimal
from a fixed point decimal byte representation.(package private) static double
getDouble(byte[] buffer, int offset, int precision, int scale)
Build a Javadouble
from a fixed point decimal byte representation.(package private) static long
getLong(byte[] buffer, int offset, int precision, int scale)
Build a Javalong
from a fixed point decimal byte representation.private static int
packedNybblesToInt(byte[] buffer, int offset, int startNybble, int numberOfNybbles)
Convert a range of packed nybbles (up to 9 digits without overflow) to an int.private static long
packedNybblesToLong(byte[] buffer, int offset, int startNybble, int numberOfNybbles)
Convert a range of packed nybbles (up to 18 digits without overflow) to a long.
-
-
-
Field Detail
-
PACKED_DECIMAL
public static final int PACKED_DECIMAL
Packed Decimal representation- See Also:
- Constant Field Values
-
msgutil
private static final MessageUtil msgutil
-
tenRadixMagnitude
private static final int[][] tenRadixMagnitude
-
-
Method Detail
-
packedNybblesToInt
private static final int packedNybblesToInt(byte[] buffer, int offset, int startNybble, int numberOfNybbles)
Convert a range of packed nybbles (up to 9 digits without overflow) to an int. Note that for performance purpose, it does not do array-out-of-bound checking.
-
packedNybblesToLong
private static final long packedNybblesToLong(byte[] buffer, int offset, int startNybble, int numberOfNybbles)
Convert a range of packed nybbles (up to 18 digits without overflow) to a long. Note that for performance purpose, it does not do array-out-of-bound checking.
-
computeMagnitude
private static final int[] computeMagnitude(int[] input)
Compute the int array of magnitude from input value segments.
-
getBigDecimal
static java.math.BigDecimal getBigDecimal(byte[] buffer, int offset, int precision, int scale)
Build ajava.math.BigDecimal
from a fixed point decimal byte representation.- Throws:
java.lang.IllegalArgumentException
- if the specified representation is not recognized.
-
getDouble
static double getDouble(byte[] buffer, int offset, int precision, int scale)
Build a Javadouble
from a fixed point decimal byte representation.- Throws:
java.lang.IllegalArgumentException
- if the specified representation is not recognized.
-
getLong
static long getLong(byte[] buffer, int offset, int precision, int scale)
Build a Javalong
from a fixed point decimal byte representation.- Throws:
java.lang.IllegalArgumentException
- if the specified representation is not recognized.java.lang.ArithmeticException
- if value is too large for a long
-
bigDecimalToPackedDecimalBytes
public static final int bigDecimalToPackedDecimalBytes(byte[] buffer, int offset, java.math.BigDecimal b, int declaredPrecision, int declaredScale) throws SqlException
Write a Javajava.math.BigDecimal
to packed decimal bytes.- Throws:
SqlException
-
-