From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28530 invoked by alias); 5 Jul 2005 18:06:54 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 28521 invoked by uid 22791); 5 Jul 2005 18:06:48 -0000 Received: from smtp-102-tuesday.nerim.net (HELO kraid.nerim.net) (62.4.16.102) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 05 Jul 2005 18:06:48 +0000 Received: from uniton.integrable-solutions.net (gdr.net1.nerim.net [62.212.99.186]) by kraid.nerim.net (Postfix) with ESMTP id DEF5B40E25 for ; Tue, 5 Jul 2005 20:06:45 +0200 (CEST) Received: from uniton.integrable-solutions.net (localhost [127.0.0.1]) by uniton.integrable-solutions.net (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id j65I5dKY007197 for ; Tue, 5 Jul 2005 20:05:39 +0200 Received: (from gdr@localhost) by uniton.integrable-solutions.net (8.12.10/8.12.10/Submit) id j65I5dWs007196; Tue, 5 Jul 2005 20:05:39 +0200 To: gcc@gcc.gnu.org Subject: Re: tr1::unordered_set bizarre rounding behavior (x86) References: <42CABDCC.3070508@suse.de> From: Gabriel Dos Reis In-Reply-To: <42CABDCC.3070508@suse.de> Date: Tue, 05 Jul 2005 18:06:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2005-07/txt/msg00175.txt.bz2 Paolo Carlini writes: | Michael Veksler wrote: | | > std::tr1::hash is implemented in a very bad way. | > it casts double to size_t, which of course does a very poor job on big | > values (is the result of 1.0e100 cast to size_t defined ?). | > | > | A possible solution would be using frexp & co to extract the mantissa | and then work on it, one way or the other. You can find it proposed | around. Then, often the exponent is simply discarded. | | What do you think? It is definitely a good thing to use the full bits of value representation if we ever want to make all "interesting" bits part of the hash value. For reasonable or sane representations it suffices to get your hand on the object representation, e.g.: const int objsize = sizeof (double); typedef unsigned char objrep_t[objsize]; double x = ....; objrep_t& p = reintepret_cast(x); // ... and let frexp and friends only for less obvious value representation. -- Gaby