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

      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​(java.math.BigDecimal x)
    • add

      public Scale add​(int n)
    • multiply

      public Scale multiply​(int multiplier)
    • 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 class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • compareTo

      public int compareTo​(Scale other)
      Specified by:
      compareTo in interface java.lang.Comparable<Scale>