Package de.tilman_neumann.jml.precision
Class Scale
- java.lang.Object
-
- de.tilman_neumann.jml.precision.Scale
-
- All Implemented Interfaces:
Comparable<Scale>
public class Scale extends Object implements Comparable<Scale>
Immutable class for precision statements in after-floating point decimal digits.- Author:
- Tilman Neumann
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Scaleadd(int n)BigDecimalapplyTo(BigDecimal x)intcompareTo(Scale other)intdigits()booleanequals(Object o)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(BigDecimal x)StringtoString()static ScalevalueOf(int digits)
-
-
-
Method Detail
-
valueOf
public static Scale valueOf(int digits)
-
of
public static Scale of(float x)
-
of
public static Scale of(double x)
-
of
public static Scale of(BigDecimal x)
-
add
public Scale add(int n)
-
multiply
public Scale multiply(int multiplier)
-
applyTo
public BigDecimal applyTo(BigDecimal x)
-
getErrorBound
public 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()
-
compareTo
public int compareTo(Scale other)
- Specified by:
compareToin interfaceComparable<Scale>
-
-