Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes

GridFloatHasheableObject Class Reference

#include <gridclientfloathasheableobject.hpp>

Inheritance diagram for GridFloatHasheableObject:
GridClientHasheableObject

List of all members.

Public Member Functions

 GridFloatHasheableObject (float pFloat)
virtual int32_t hashCode () const
virtual void convertToBytes (std::vector< int8_t > &bytes) const
virtual bool operator< (const GridFloatHasheableObject &right) const

Static Public Member Functions

static int32_t floatToIntBits (float val)
static float intBitsToFloat (int bits)

Static Protected Member Functions

static int floatToRawIntBits (float val)

Protected Attributes

float floatVal

Detailed Description

Provide the implementation of hash-code for the float type.


Constructor & Destructor Documentation

GridFloatHasheableObject::GridFloatHasheableObject ( float  pFloatVal  ) 

Public constructor.

Parameters:
pFloatVal Value to hold.

Member Function Documentation

void GridFloatHasheableObject::convertToBytes ( std::vector< int8_t > &  bytes  )  const [virtual]

Converts contained object to byte vector.

Parameters:
bytes Vector to fill.

Implements GridClientHasheableObject.

int32_t GridFloatHasheableObject::floatToIntBits ( float  val  )  [static]

Returns int value based on float bits representation.

Parameters:
val float value.
Returns:
int value with the same bit pattern.

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.

Bit 31 (the bit that is selected by the mask 0x80000000) represents the sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask 0x7f800000) represent the exponent. Bits 22-0 (the bits that are selected by the mask 0x007fffff) represent the significand (sometimes called the mantissa) of the floating-point number.

If the argument is positive infinity, the result is 0x7f800000.

If the argument is negative infinity, the result is 0xff800000.

If the argument is NaN, the result is 0x7fc00000.

In all cases, the result is an integer that, when given to the intBitsToFloat(int) method, will produce a floating-point value the same as the argument to floatToIntBits (except all NaN values are collapsed to a single "canonical" NaN value).

Parameters:
value a floating-point number.
Returns:
the bits that represent the floating-point number.
int32_t GridFloatHasheableObject::floatToRawIntBits ( float  val  )  [static, protected]

Returns int value based on float bits representation.

Parameters:
val float value.
Returns:
int value with the same bit pattern.

Returns int value based on float bits representation.

Parameters:
val Float value.
Returns:
int32_t value with the same bit pattern.
int32_t GridFloatHasheableObject::hashCode (  )  const [virtual]

Calculates hash code for the contained object.

Returns:
Hash code.

Returns a hash code for this float value.

Returns:
a hash code value for this object.

Implements GridClientHasheableObject.

float GridFloatHasheableObject::intBitsToFloat ( int  bits  )  [static]

Returns float value based on int bits representation.

Parameters:
bits int value.
Returns:
float value with the same bit pattern.

Returns the float value corresponding to a given bit representation. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single format" bit layout.

If the argument is 0x7f800000, the result is positive infinity.

If the argument is 0xff800000, the result is negative infinity.

If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns. Distinct values of NaN are only distinguishable by use of the Float.floatToRawIntBits method.

In all other cases, let s, e, and m be three values that can be computed from the argument: <blockquote>

 int s = ((bits >> 31) == 0) ? 1 : -1;
 int e = ((bits >> 23) & 0xff);
 int m = (e == 0) ?
                 (bits & 0x7fffff) << 1 :
                 (bits & 0x7fffff) | 0x800000;
 

</blockquote> Then the floating-point result equals the value of the mathematical expression sm2e-150.

Note that this method may not be able to return a float NaN with exactly same bit pattern as the int argument. IEEE 754 distinguishes between two kinds of NaNs, quiet NaNs and signaling NaNs. The differences between the two kinds of NaN are generally not visible in Java. Arithmetic operations on signaling NaNs turn them into quiet NaNs with a different, but often similar, bit pattern. However, on some processors merely copying a signaling NaN also performs that conversion. In particular, copying a signaling NaN to return it to the calling method may perform this conversion. So intBitsToFloat may not be able to return a float with a signaling NaN bit pattern. Consequently, for some int values, floatToRawIntBits(intBitsToFloat(start)) may not equal start. Moreover, which particular bit patterns represent signaling NaNs is platform dependent; although all NaN bit patterns, quiet or signaling, must be in the NaN range identified above.

Parameters:
bits an integer.
Returns:
the float floating-point value with the same bit pattern.
bool GridFloatHasheableObject::operator< ( const GridFloatHasheableObject &  right  )  const [virtual]

Compares with another object of this type.

Returns:
True if the right operand is greater than this object.

Member Data Documentation

Value held.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends