com.sun.j3d.internal
Class HashCodeUtil

java.lang.Object
  extended by com.sun.j3d.internal.HashCodeUtil

public class HashCodeUtil
extends java.lang.Object

Utility class used when computing the hash code for objects containing float or double values. This fixes Issue 36.


Constructor Summary
private HashCodeUtil()
          Do not construct an instance of this class.
 
Method Summary
static long doubleToLongBits(double d)
          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.
static int floatToIntBits(float f)
          Returns the representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout, after first mapping -0.0 to 0.0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashCodeUtil

private HashCodeUtil()
Do not construct an instance of this class.

Method Detail

floatToIntBits

public static int floatToIntBits(float f)
Returns the representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout, after first mapping -0.0 to 0.0. This method is identical to Float.floatToIntBits(float) except that an integer value of 0 is returned for a floating-point value of -0.0f. This is done for the purpose of computing a hash code that satisfies the contract of hashCode() and equals(). The equals() method in some Java 3D classes does a pair-wise "==" test on each floating-point field in the class. Since 0.0f == -0.0f returns true, we must also return the same hash code for two objects, one of which has a field with a value of -0.0f and the other of which has a cooresponding field with a value of 0.0f.

Parameters:
f - an input floating-point number
Returns:
the integer bits representing that floating-point number, after first mapping -0.0f to 0.0f

doubleToLongBits

public static long doubleToLongBits(double d)
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 0L is returned for a floating-point value of -0.0. This is done for the purpose of computing a hash code that satisfies the contract of hashCode() and equals(). The equals() method in some Java 3D classes does a pair-wise "==" test on each floating-point field in the class. Since 0.0 == -0.0 returns true, we must also return the same hash code for two objects, one of which has a field with a value of -0.0 and the other of which has a cooresponding field with a value of 0.0.

Parameters:
d - an input double precision floating-point number
Returns:
the integer bits representing that floating-point number, after first mapping -0.0f to 0.0f


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.