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 Scale
add(int n)
java.math.BigDecimal
applyTo(java.math.BigDecimal x)
int
compareTo(Scale other)
int
digits()
boolean
equals(java.lang.Object o)
java.math.BigDecimal
getErrorBound()
The error a computation with this scale should not exceed.int
hashCode()
Scale
multiply(int multiplier)
static Scale
of(double x)
static Scale
of(float x)
static Scale
of(java.math.BigDecimal x)
java.lang.String
toString()
static Scale
valueOf(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:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<Scale>
-