Class Decimals

java.lang.Object
io.trino.spi.type.Decimals

public final class Decimals extends Object
  • Field Details

    • MAX_UNSCALED_DECIMAL

      public static final Int128 MAX_UNSCALED_DECIMAL
    • MIN_UNSCALED_DECIMAL

      public static final Int128 MIN_UNSCALED_DECIMAL
    • MAX_PRECISION

      public static final int MAX_PRECISION
      See Also:
    • MAX_SHORT_PRECISION

      public static final int MAX_SHORT_PRECISION
      See Also:
  • Method Details

    • longTenToNth

      public static long longTenToNth(int n)
    • bigIntegerTenToNth

      public static BigInteger bigIntegerTenToNth(int n)
    • parse

      public static DecimalParseResult parse(String stringValue)
    • encodeShortScaledValue

      public static long encodeShortScaledValue(BigDecimal value, int scale)
    • encodeShortScaledValue

      public static long encodeShortScaledValue(BigDecimal value, int scale, RoundingMode roundingMode)
    • encodeScaledValue

      public static Int128 encodeScaledValue(BigDecimal value, int scale)
    • encodeScaledValue

      public static Int128 encodeScaledValue(BigDecimal value, int scale, RoundingMode roundingMode)
    • toString

      public static String toString(long unscaledValue, int scale)
    • toString

      public static String toString(Int128 unscaledValue, int scale)
    • toString

      public static String toString(BigInteger unscaledValue, int scale)
    • overflows

      public static boolean overflows(long value, int precision)
    • overflows

      public static boolean overflows(BigInteger value, int precision)
    • overflows

      public static boolean overflows(BigDecimal value, long precision)
    • readBigDecimal

      public static BigDecimal readBigDecimal(DecimalType type, Block block, int position)
    • writeBigDecimal

      public static void writeBigDecimal(DecimalType decimalType, BlockBuilder blockBuilder, BigDecimal value)
    • rescale

      public static BigDecimal rescale(BigDecimal value, DecimalType type)
    • writeShortDecimal

      public static void writeShortDecimal(BlockBuilder blockBuilder, long value)
    • rescale

      public static long rescale(long value, int fromScale, int toScale)
    • rescale

      public static BigInteger rescale(BigInteger value, int fromScale, int toScale)
    • valueOf

      public static Int128 valueOf(BigDecimal value)
      Converts BigDecimal to Int128 representing it for long DecimalType. It is caller responsibility to ensure that value.scale() equals to DecimalType.getScale().
    • valueOfShort

      public static long valueOfShort(BigDecimal value)
      Converts BigDecimal to long representing it for short DecimalType. It is caller responsibility to ensure that value.scale() equals to DecimalType.getScale().
    • valueOf

      public static long valueOf(long value)
    • valueOf

      public static Int128 valueOf(BigInteger value)
    • overflows

      public static boolean overflows(Int128 value)
    • overflows

      public static boolean overflows(long high, long low)
    • overflows

      public static boolean overflows(Int128 value, int precision)