Package de.tilman_neumann.jml.precision
Class Magnitude
- java.lang.Object
-
- de.tilman_neumann.jml.precision.Magnitude
-
public class Magnitude extends 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
All Methods Static Methods Concrete Methods 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(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(BigDecimal x)
static int
of(BigInteger n)
Gives the absolute size of n in decimal digits.
-
-
-
Method Detail
-
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(BigDecimal x)
-
of
public static int of(BigRational q)
-
of
public static int of(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(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
-
-