Class NumericConverterImpl

  • All Implemented Interfaces:
    NumericConverter

    public class NumericConverterImpl
    extends Object
    implements NumericConverter
    This is a concrete implementation class for numeric conversion to BigDecimal or BigInteger. For conversion to BigInteger, we truncate the fraction part of the number.
    Author:
    Shing Wai Chan
    • Constructor Detail

      • NumericConverterImpl

        public NumericConverterImpl()
    • Method Detail

      • toBigDecimal

        public BigDecimal toBigDecimal​(BigInteger bInteger)
        To convert BigInteger to BigDecimal.
        Specified by:
        toBigDecimal in interface NumericConverter
        Parameters:
        bInteger - the BigInteger to be converted
        Returns:
        converted BigDecimal
      • toBigDecimal

        public BigDecimal toBigDecimal​(Double d)
        To convert Double to BigDecimal.
        Specified by:
        toBigDecimal in interface NumericConverter
        Parameters:
        d - the Double to be converted
        Returns:
        converted BigDecimal
      • toBigDecimal

        public BigDecimal toBigDecimal​(Float f)
        To convert Float to BigDecimal.
        Specified by:
        toBigDecimal in interface NumericConverter
        Parameters:
        f - the Float to be converted
        Returns:
        converted BigDecimal
      • toBigDecimal

        public BigDecimal toBigDecimal​(Number n)
        To convert Number other than BigInteger, Double and Float to BigDecimal.
        Specified by:
        toBigDecimal in interface NumericConverter
        Parameters:
        n - the Number to be converted
        Returns:
        converted BigDecimal
      • toBigInteger

        public BigInteger toBigInteger​(BigDecimal bDecimal)
        To convert BigDecimal to BigInteger.
        Specified by:
        toBigInteger in interface NumericConverter
        Parameters:
        bDecimal - the BigDecimal to be converted
        Returns:
        converted BigInteger
      • toBigInteger

        public BigInteger toBigInteger​(Double d)
        To convert Double to BigInteger.
        Specified by:
        toBigInteger in interface NumericConverter
        Parameters:
        d - the Double to be converted
        Returns:
        converted BigInteger
      • toBigInteger

        public BigInteger toBigInteger​(Float f)
        To convert Float to BigInteger.
        Specified by:
        toBigInteger in interface NumericConverter
        Parameters:
        f - the Float to be converted
        Returns:
        converted BigInteger
      • toBigInteger

        public BigInteger toBigInteger​(Number n)
        To convert Number other than BigDecimal, Double and Float to BigInteger.
        Specified by:
        toBigInteger in interface NumericConverter
        Parameters:
        n - the Number to be converted
        Returns:
        converted BigInteger