Class DecimalDataUtils


  • public final class DecimalDataUtils
    extends Object
    Utilities for DecimalData.

    Note: we have to put this class under the same package with DecimalData to make it possible to access package-accessing member variables.

    • Field Detail

      • DECIMAL_SYSTEM_DEFAULT

        public static final DecimalType DECIMAL_SYSTEM_DEFAULT
    • Constructor Detail

      • DecimalDataUtils

        public DecimalDataUtils()
    • Method Detail

      • doubleValue

        public static double doubleValue​(DecimalData decimal)
      • signum

        public static int signum​(DecimalData decimal)
        Returns the signum function of this decimal. (The return value is -1 if this decimal is negative; 0 if this decimal is zero; and 1 if this decimal is positive.)
        Returns:
        the signum function of this decimal.
      • divideToIntegralValue

        public static DecimalData divideToIntegralValue​(DecimalData value,
                                                        DecimalData divisor,
                                                        int precision,
                                                        int scale)
        Returns a DecimalData whose value is the integer part of the quotient (this / divisor) rounded down.
        Parameters:
        value - value by which this DecimalData is to be divided.
        divisor - value by which this DecimalData is to be divided.
        Returns:
        The integer part of this / divisor.
        Throws:
        ArithmeticException - if divisor==0
      • castToIntegral

        public static long castToIntegral​(DecimalData dec)
      • castFrom

        public static DecimalData castFrom​(String string,
                                           int precision,
                                           int scale)
      • castFrom

        public static DecimalData castFrom​(double val,
                                           int p,
                                           int s)
      • castFrom

        public static DecimalData castFrom​(long val,
                                           int p,
                                           int s)
      • castToBoolean

        public static boolean castToBoolean​(DecimalData dec)
      • sign

        public static DecimalData sign​(DecimalData b0)
        SQL SIGN operator applied to BigDecimal values. preserve precision and scale.
      • compare

        public static int compare​(DecimalData b1,
                                  long n2)
      • compare

        public static int compare​(DecimalData b1,
                                  double n2)
      • compare

        public static int compare​(long n1,
                                  DecimalData b2)
      • compare

        public static int compare​(double n1,
                                  DecimalData b2)
      • sround

        public static DecimalData sround​(DecimalData b0,
                                         int r)
        SQL ROUND operator applied to BigDecimal values.
      • power10

        public static long power10​(int n)
      • is32BitDecimal

        public static boolean is32BitDecimal​(int precision)
      • is64BitDecimal

        public static boolean is64BitDecimal​(int precision)
      • isByteArrayDecimal

        public static boolean isByteArrayDecimal​(int precision)