Java Double to Long doubleToLongBits(final double d)

Here you can find the source of doubleToLongBits(final double d)

Description

Returns the representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout, after first mapping -0.0 to 0.0.

License

Open Source License

Parameter

Parameter Description
f an input floating-point number

Return

the integer bits representing that floating-point number, after first mapping -0.0f to 0.0f

Declaration

public static final long doubleToLongBits(final double d) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w  w w.  ja va  2  s.  c o m*/
     * Returns the representation of the specified floating-point
     * value according to the IEEE 754 floating-point "double format"
     * bit layout, after first mapping -0.0 to 0.0. This method is
     * identical to Double.doubleToLongBits(double) except that an integer
     * value of 0 is returned for a floating-point value of
     * -0.0d. This is done for the purpose of computing a hash code
     * that satisfies the contract of hashCode() and equals(). The
     * equals() method in each vecmath class does a pair-wise "=="
     * test on each floating-point field in the class (e.g., x, y, and
     * z for a Tuple3d). Since 0.0d == -0.0d returns true,
     * we must also return the same hash code for two objects, one of
     * which has a field with a value of -0.0d and the other of which
     * has a corresponding field with a value of 0.0d.
     *
     * @param f an input floating-point number
     * @return the integer bits representing that floating-point
     * number, after first mapping -0.0f to 0.0f
     */
    public static final long doubleToLongBits(final double d) {
        // Check for +0 or -0
        return ((d == 0.0d) ? 0l : Double.doubleToLongBits(d));
    }
}

Related

  1. doubleToLong(final double d)
  2. DoubleToLong_With_Little_Endian(double dd)
  3. doubleToLongArray(final double value)
  4. doubleToLongBits(double val)
  5. doubleToLongBits(double value)
  6. doubleToLongBits(final double v)
  7. doubleToRawLongBits(double d)
  8. doubleToRawLongBits(double value)
  9. doubleToS390LongBits(double ieeeDouble)