Package de.tilman_neumann.jml.precision
Class Scale
java.lang.Object
de.tilman_neumann.jml.precision.Scale
- All Implemented Interfaces:
java.lang.Comparable<Scale>
public class Scale extends java.lang.Object implements java.lang.Comparable<Scale>
Immutable class for precision statements in after-floating point decimal digits.
-
Method Summary
Modifier and Type Method Description Scaleadd(int n)java.math.BigDecimalapplyTo(java.math.BigDecimal x)intcompareTo(Scale other)intdigits()booleanequals(java.lang.Object o)java.math.BigDecimalgetErrorBound()The error a computation with this scale should not exceed.inthashCode()Scalemultiply(int multiplier)static Scaleof(double x)static Scaleof(float x)static Scaleof(java.math.BigDecimal x)java.lang.StringtoString()static ScalevalueOf(int digits)Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Method Details
-
valueOf
-
of
-
of
-
of
-
add
-
multiply
-
applyTo
public java.math.BigDecimal applyTo(java.math.BigDecimal x) -
getErrorBound
public java.math.BigDecimal getErrorBound()The error a computation with this scale should not exceed. This is just half of an ulp for values with this scale, thus computation results should be correct to this scale after rounding.- Returns:
- maximum allowed error
-
digits
public int digits() -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<Scale>
-