Class BigFloat.Context

java.lang.Object
ch.obermuhlner.math.big.BigFloat.Context
All Implemented Interfaces:
Serializable
Enclosing class:
BigFloat

public static class BigFloat.Context extends Object implements Serializable
Manages the MathContext and provides factory methods for BigFloat values.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getMathContext

      public 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 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(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(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:
      NumberFormatException - if the value is not a valid number.
    • pi

      public BigFloat pi()
      Returns the constant pi with this context.
      Returns:
      pi with this context (rounded to the precision of this context)
      See Also:
    • e

      public BigFloat e()
      Returns the constant e with this context.
      Returns:
      e with this context (rounded to the precision of this context)
      See Also:
    • 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:
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object