Class Magnitude

java.lang.Object
de.tilman_neumann.jml.precision.Magnitude

public class Magnitude
extends java.lang.Object
  • Field Summary

    Fields
    Modifier and Type Field Description
    static double LOG10_TO_LOG2_MULTIPLIER
    Multiplier to convert log10-values to log2-values.
    static double LOG2_TO_LOG10_MULTIPLIER
    Multiplier to convert log2-values to log10-values.
  • Constructor Summary

    Constructors
    Constructor Description
    Magnitude()  
  • Method Summary

    Modifier and Type Method Description
    static int binaryToDecimal​(int binaryDigits)
    Compute the number of decimal digits analogous to the specified number of binary digits.
    static int bitsOf​(java.math.BigInteger n)
    Gives the size of absolute |n| in bits: 0 for 0, 1 for +-1, 2 for +-2, 2 for +-3, 3 for +-4, ...
    static int decimalToBinary​(int decimalDigits)
    Computes the number of binary digits analogous to the specified number of decimal digits.
    static int of​(double x)  
    static int of​(float x)  
    static int of​(long x)  
    static int of​(BigRational q)  
    static int of​(java.math.BigDecimal x)  
    static int of​(java.math.BigInteger n)
    Gives the absolute size of n in decimal digits.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG2_TO_LOG10_MULTIPLIER

      public static final double LOG2_TO_LOG10_MULTIPLIER
      Multiplier to convert log2-values to log10-values.
    • LOG10_TO_LOG2_MULTIPLIER

      public static final double LOG10_TO_LOG2_MULTIPLIER
      Multiplier to convert log10-values to log2-values.
  • Constructor Details

    • Magnitude

      public Magnitude()
  • Method Details

    • of

      public static int of​(long x)
    • of

      public static int of​(float x)
    • of

      public static int of​(double x)
    • of

      public static int of​(java.math.BigDecimal x)
    • of

      public static int of​(BigRational q)
    • of

      public static int of​(java.math.BigInteger n)
      Gives the absolute size of n in decimal digits. Fast for an exact implementation.
      Parameters:
      n -
      Returns:
      magnitude of n in decimal digits
    • bitsOf

      public static int bitsOf​(java.math.BigInteger n)
      Gives the size of absolute |n| in bits: 0 for 0, 1 for +-1, 2 for +-2, 2 for +-3, 3 for +-4, ...
      Parameters:
      n -
      Returns:
      number of bits of |n|
    • decimalToBinary

      public static int decimalToBinary​(int decimalDigits)
      Computes the number of binary digits analogous to the specified number of decimal digits.
      Parameters:
      decimalDigits - Number of decimal digits
      Returns:
      number of binary digits
    • binaryToDecimal

      public static int binaryToDecimal​(int binaryDigits)
      Compute the number of decimal digits analogous to the specified number of binary digits.
      Parameters:
      binaryDigits - Number of binary digits
      Returns:
      number of decimal digits