diff options
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/src/hash-long-double-aux.cc | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 564f905cbe0..ef97ea3c0cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2010-02-28 Paolo Carlini <paolo.carlini@oracle.com> + + * src/hash-long-double-aux.cc (hash<long double>:: + operator()(long double)): Hash both -0 and +0 to 0. + 2010-02-25 Ed Smith-Rowland <3dw4rd@verizon.net> * include/bits/random.tcc (operator<<): Use max_digits10. diff --git a/libstdc++-v3/src/hash-long-double-aux.cc b/libstdc++-v3/src/hash-long-double-aux.cc index 5b8bbfdd49d..d54d635f83e 100644 --- a/libstdc++-v3/src/hash-long-double-aux.cc +++ b/libstdc++-v3/src/hash-long-double-aux.cc @@ -28,7 +28,9 @@ size_t hash<long double>::operator()(long double __val) const { - size_t __result = 0; + // 0 and -0 both hash to zero. + if (__val == 0.0L) + return 0; int __exponent; __val = __builtin_frexpl(__val, &__exponent); @@ -44,7 +46,5 @@ const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__; - __result = __hibits + (size_t)__val + __coeff * __exponent; - - return __result; + return __hibits + (size_t)__val + __coeff * __exponent; } |