Class BigFloat.Context

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    BigFloat

    public static class BigFloat.Context
    extends java.lang.Object
    implements java.io.Serializable
    Manages the MathContext and provides factory methods for BigFloat values.
    See Also:
    Serialized Form
    • Field Detail

      • NEGATIVE_ONE

        public final BigFloat NEGATIVE_ONE
      • mathContext

        private final java.math.MathContext mathContext
    • Constructor Detail

      • Context

        private Context​(java.math.MathContext mathContext)
    • Method Detail

      • getMathContext

        public java.math.MathContext getMathContext()
        Returns the MathContext of this context.
        Returns:
        the MathContext
      • getPrecision

        public int getPrecision()
        Returns the precision of this context.

        This is equivalent to calling getMathContext().getPrecision().

        Returns:
        the precision
      • getRoundingMode

        public java.math.RoundingMode getRoundingMode()
        Returns the RoundingMode of this context.

        This is equivalent to calling getMathContext().getRoundingMode().

        Returns:
        the RoundingMode
      • valueOf

        public BigFloat valueOf​(BigFloat value)
        Creates a BigFloat value with this context.
        Parameters:
        value - the source BigFloat value
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(java.math.BigDecimal value)
        Creates a BigFloat value with this context.
        Parameters:
        value - the source BigDecimal value
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(int value)
        Creates a BigFloat value with this context.
        Parameters:
        value - the source int value
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(int value,
                                boolean unsigned)
        parse unsigned value with this logic
        value & 4294967295
        Parameters:
        value - an int value
        unsigned - if true value will parse as unsigned integer
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(long value)
        Creates a BigFloat value with this context.
        Parameters:
        value - the source long value
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(long value,
                                boolean unsigned)
        parse unsigned value with this logic
        value & 18446744073709551615
        Parameters:
        value - an int value
        unsigned - if true value will parse as unsigned integer
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(double value)
        Creates a BigFloat value with this context.
        Parameters:
        value - the source double value
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
      • valueOf

        public BigFloat valueOf​(java.lang.String value)
        Creates a BigFloat value with this context.
        Parameters:
        value - the source String value
        Returns:
        the BigFloat value with this context (rounded to the precision of this context)
        Throws:
        java.lang.NumberFormatException - if the value is not a valid number.
      • factorial

        public BigFloat factorial​(int n)
        Returns the factorial of n with this context.
        Parameters:
        n - the value to calculate
        Returns:
        the factorial of n with this context (rounded to the precision of this context)
        See Also:
        BigDecimalMath.factorial(int)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object