Package sun.misc

Class FloatingDecimal


  • public class FloatingDecimal
    extends Object
    A class for converting between ASCII and decimal representations of a single or double precision floating point number. Most conversions are provided via static convenience methods, although a BinaryToASCIIConverter instance may be obtained and reused.
    • Constructor Detail

      • FloatingDecimal

        public FloatingDecimal()
    • Method Detail

      • numberOfLeadingZeros

        public static int numberOfLeadingZeros​(long i)
        Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long value. Returns 64 if the specified value has no one-bits in its two's complement representation, in other words if it is equal to zero.

        Note that this method is closely related to the logarithm base 2. For all positive long values x:

        • floor(log2(x)) = 63 - numberOfLeadingZeros(x)
        • ceil(log2(x)) = 64 - numberOfLeadingZeros(x - 1)
        Parameters:
        i - the value whose number of leading zeros is to be computed
        Returns:
        the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long value, or 64 if the value is equal to zero.
        Since:
        1.5
      • numberOfTrailingZeros

        public static int numberOfTrailingZeros​(long i)
        Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long value. Returns 64 if the specified value has no one-bits in its two's complement representation, in other words if it is equal to zero.
        Parameters:
        i - the value whose number of trailing zeros is to be computed
        Returns:
        the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long value, or 64 if the value is equal to zero.
        Since:
        1.5