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.SerializableManages theMathContextand provides factory methods forBigFloatvalues.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.math.MathContextmathContextBigFloatNEGATIVE_ONEBigFloatONEprivate static longserialVersionUIDBigFloatZERO
-
Constructor Summary
Constructors Modifier Constructor Description privateContext(java.math.MathContext mathContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigFloate()Returns the constant e with this context.booleanequals(java.lang.Object obj)BigFloatfactorial(int n)Returns the factorial of n with this context.java.math.MathContextgetMathContext()Returns theMathContextof this context.intgetPrecision()Returns the precision of this context.java.math.RoundingModegetRoundingMode()Returns theRoundingModeof this context.inthashCode()BigFloatpi()Returns the constant pi with this context.java.lang.StringtoString()BigFloatvalueOf(double value)Creates aBigFloatvalue with this context.BigFloatvalueOf(int value)Creates aBigFloatvalue with this context.BigFloatvalueOf(int value, boolean unsigned)parse unsigned value with this logicBigFloatvalueOf(long value)Creates aBigFloatvalue with this context.BigFloatvalueOf(long value, boolean unsigned)parse unsigned value with this logicBigFloatvalueOf(BigFloat value)Creates aBigFloatvalue with this context.BigFloatvalueOf(java.lang.String value)Creates aBigFloatvalue with this context.BigFloatvalueOf(java.math.BigDecimal value)Creates aBigFloatvalue 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 theMathContextof 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 theRoundingModeof this context.This is equivalent to calling
getMathContext().getRoundingMode().- Returns:
- the
RoundingMode
-
valueOf
public BigFloat valueOf(java.math.BigDecimal value)
Creates aBigFloatvalue with this context.- Parameters:
value- the sourceBigDecimalvalue- Returns:
- the
BigFloatvalue with this context (rounded to the precision of this context)
-
valueOf
public BigFloat valueOf(int value)
Creates aBigFloatvalue with this context.- Parameters:
value- the source int value- Returns:
- the
BigFloatvalue 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
BigFloatvalue with this context (rounded to the precision of this context)
-
valueOf
public BigFloat valueOf(long value)
Creates aBigFloatvalue with this context.- Parameters:
value- the source long value- Returns:
- the
BigFloatvalue 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
BigFloatvalue with this context (rounded to the precision of this context)
-
valueOf
public BigFloat valueOf(double value)
Creates aBigFloatvalue with this context.- Parameters:
value- the source double value- Returns:
- the
BigFloatvalue with this context (rounded to the precision of this context)
-
valueOf
public BigFloat valueOf(java.lang.String value)
Creates aBigFloatvalue with this context.- Parameters:
value- the source String value- Returns:
- the
BigFloatvalue 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-