Package com.rosetta.model.lib
Class RosettaNumber
java.lang.Object
java.lang.Number
com.rosetta.model.lib.RosettaNumber
- All Implemented Interfaces:
Serializable,Comparable<RosettaNumber>
An implementation of the IEEE754 decimal128 standard. Under the hood, this class uses
BigDecimal. Also see
MathContext.DECIMAL128.
(Actually, *almost* an implementation of the decimal128 standard.
See section "Relation to IEEE 754 Decimal Arithmetic" in the
BigDecimal documentation for edge cases:
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/BigDecimal.html
)
Note that this class circumvents problems caused by a
per-instance precision, like in BigDecimal.
E.g., for equality, see https://stackoverflow.com/q/6787142/3083982- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MathContextstatic final RosettaNumberstatic final RosettaNumber -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(RosettaNumber other) intdivide(RosettaNumber other) doublebooleanfloatinthashCode()intintValue()longmultiply(RosettaNumber other) subtract(RosettaNumber other) toString()static RosettaNumbervalueOf(double value) static RosettaNumbervalueOf(long value) static RosettaNumbervalueOf(BigDecimal value) static RosettaNumbervalueOf(BigInteger value) Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
DECIMAL_PRECISION
-
ZERO
-
ONE
-
-
Constructor Details
-
RosettaNumber
-
-
Method Details
-
valueOf
-
valueOf
-
valueOf
-
valueOf
-
add
-
subtract
-
multiply
-
divide
-
equals
-
hashCode
public int hashCode() -
toString
-
intValue
public int intValue() -
longValue
public long longValue() -
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
bigIntegerValue
-
bigDecimalValue
-
compareTo
- Specified by:
compareToin interfaceComparable<RosettaNumber>
-