Class Magnitude


  • public class Magnitude
    extends Object
    • Field Detail

      • 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 Detail

      • Magnitude

        public Magnitude()
    • 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​(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