Package ch.obermuhlner.math.big
Class BigFloat.Context
- java.lang.Object
-
- ch.obermuhlner.math.big.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 theMathContext
and provides factory methods forBigFloat
values.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.math.MathContext
mathContext
BigFloat
NEGATIVE_ONE
BigFloat
ONE
private static long
serialVersionUID
BigFloat
ZERO
-
Constructor Summary
Constructors Modifier Constructor Description private
Context(java.math.MathContext mathContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigFloat
e()
Returns the constant e with this context.boolean
equals(java.lang.Object obj)
BigFloat
factorial(int n)
Returns the factorial of n with this context.java.math.MathContext
getMathContext()
Returns theMathContext
of this context.int
getPrecision()
Returns the precision of this context.java.math.RoundingMode
getRoundingMode()
Returns theRoundingMode
of this context.int
hashCode()
BigFloat
pi()
Returns the constant pi with this context.java.lang.String
toString()
BigFloat
valueOf(double value)
Creates aBigFloat
value with this context.BigFloat
valueOf(int value)
Creates aBigFloat
value with this context.BigFloat
valueOf(int value, boolean unsigned)
parse unsigned value with this logicBigFloat
valueOf(long value)
Creates aBigFloat
value with this context.BigFloat
valueOf(long value, boolean unsigned)
parse unsigned value with this logicBigFloat
valueOf(BigFloat value)
Creates aBigFloat
value with this context.BigFloat
valueOf(java.lang.String value)
Creates aBigFloat
value with this context.BigFloat
valueOf(java.math.BigDecimal value)
Creates aBigFloat
value with this context.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
NEGATIVE_ONE
public final BigFloat NEGATIVE_ONE
-
ZERO
public final BigFloat ZERO
-
ONE
public final BigFloat ONE
-
mathContext
private final java.math.MathContext mathContext
-
-
Method Detail
-
getMathContext
public java.math.MathContext getMathContext()
Returns theMathContext
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 theRoundingMode
of this context.This is equivalent to calling
getMathContext().getRoundingMode()
.- Returns:
- the
RoundingMode
-
valueOf
public BigFloat valueOf(java.math.BigDecimal value)
Creates aBigFloat
value with this context.- Parameters:
value
- the sourceBigDecimal
value- Returns:
- the
BigFloat
value with this context (rounded to the precision of this context)
-
valueOf
public BigFloat valueOf(int value)
Creates aBigFloat
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 logicvalue & 4294967295
- Parameters:
value
- an int valueunsigned
- 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 aBigFloat
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 logicvalue & 18446744073709551615
- Parameters:
value
- an int valueunsigned
- 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 aBigFloat
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 aBigFloat
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.
-
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:
BigDecimalMath.pi(MathContext)
-
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:
BigDecimalMath.e(MathContext)
-
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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-