#include <gridclientdoublehasheableobject.hpp>
Public Member Functions | |
| GridDoubleHasheableObject (double pDoubleVal) | |
| virtual int32_t | hashCode () const |
| virtual void | convertToBytes (std::vector< int8_t > &bytes) const |
| virtual bool | operator< (const GridDoubleHasheableObject &right) const |
Static Public Member Functions | |
| static int64_t | doubleToLongBits (double doubleVal) |
| static double | longBitsToDouble (const int64_t &bits) |
Static Protected Member Functions | |
| static int64_t | doubleToRawLongBits (double val) |
Protected Attributes | |
| double | doubleVal |
Provide the implementation of hash-code for the double type.
| GridDoubleHasheableObject::GridDoubleHasheableObject | ( | double | pDoubleVal | ) |
Public constructor.
| pDoubleVal | Value to hold. |
| void GridDoubleHasheableObject::convertToBytes | ( | std::vector< int8_t > & | bytes | ) | const [virtual] |
Converts contained object to byte vector.
| bytes | Vector to fill. |
Implements GridClientHasheableObject.
| int64_t GridDoubleHasheableObject::doubleToLongBits | ( | double | doubleVal | ) | [static] |
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.
| doubleVal | a double precision floating-point number. |
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.
Bit 63 (the bit that is selected by the mask 0x8000000000000000L) represents the sign of the floating-point number. Bits 62-52 (the bits that are selected by the mask 0x7ff0000000000000L) represent the exponent. Bits 51-0 (the bits that are selected by the mask 0x000fffffffffffffL) represent the significand (sometimes called the mantissa) of the floating-point number.
If the argument is positive infinity, the result is 0x7ff0000000000000L.
If the argument is negative infinity, the result is 0xfff0000000000000L.
If the argument is NaN, the result is 0x7ff8000000000000L.
In all cases, the result is a long integer that, when given to the longBitsToDouble(long) method, will produce a floating-point value the same as the argument to doubleToLongBits (except all NaN values are collapsed to a single "canonical" NaN value).
| doubleVal | a double precision floating-point number. |
| int64_t GridDoubleHasheableObject::doubleToRawLongBits | ( | double | val | ) | [static, protected] |
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout, preserving Not-a-Number (NaN) values.
| value | a double precision floating-point number. |
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout, preserving Not-a-Number (NaN) values.
Bit 63 (the bit that is selected by the mask 0x8000000000000000L) represents the sign of the floating-point number. Bits 62-52 (the bits that are selected by the mask 0x7ff0000000000000L) represent the exponent. Bits 51-0 (the bits that are selected by the mask 0x000fffffffffffffL) represent the significant (sometimes called the mantissa) of the floating-point number.
If the argument is positive infinity, the result is 0x7ff0000000000000L.
If the argument is negative infinity, the result is 0xfff0000000000000L.
If the argument is NaN, the result is the long integer representing the actual NaN value. Unlike the doubleToLongBits method, doubleToRawLongBits does not collapse all the bit patterns encoding a NaN to a single "canonical" NaN value.
In all cases, the result is a long integer that, when given to the longBitsToDouble(long) method, will produce a floating-point value the same as the argument to doubleToRawLongBits.
| value | a double precision floating-point number. |
| int32_t GridDoubleHasheableObject::hashCode | ( | ) | const [virtual] |
Calculates hash code for the contained object.
Returns a hash code for this Double object. The result is the exclusive OR of the two halves of the long integer bit representation, exactly as produced by the method doubleToLongBits(double), of the primitive double value represented by this Double object. That is, the hash code is the value of the expression: <blockquote>
(int)(v^(v>>>32))
</blockquote> where v is defined by: <blockquote>
long v = Double.doubleToLongBits(this.doubleValue());
</blockquote>
hash code value for this object. Implements GridClientHasheableObject.
| double GridDoubleHasheableObject::longBitsToDouble | ( | const int64_t & | bits | ) | [static] |
Returns the double value corresponding to a given bit representation.
| bits | any long integer. |
double floating-point value with the same bit pattern.Returns the double 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 "double format" bit layout.
If the argument is 0x7ff0000000000000L, the result is positive infinity.
If the argument is 0xfff0000000000000L, the result is negative infinity.
If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL, 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 Double.doubleToRawLongBits method.
In all other cases, let s, e, and m be three values that can be computed from the argument: <blockquote>
int s = ((bits >> 63) == 0) ? 1 : -1;
int e = (int)((bits >> 52) & 0x7ffL);
long m = (e == 0) ?
(bits & 0xfffffffffffffL) << 1 :
(bits & 0xfffffffffffffL) | 0x10000000000000L;
</blockquote> Then the floating-point result equals the value of the mathematical expression sm2e-1075.
Note that this method may not be able to return a double NaN with exactly same bit pattern as the long 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 longBitsToDouble may not be able to return a double with a signaling NaN bit pattern. Consequently, for some long values, doubleToRawLongBits(longBitsToDouble(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.
| bits | any long integer. |
double floating-point value with the same bit pattern. | bool GridDoubleHasheableObject::operator< | ( | const GridDoubleHasheableObject & | right | ) | const [virtual] |
Compares with another object of this type.
double GridDoubleHasheableObject::doubleVal [protected] |
Value stored.
1.7.1