From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21934 invoked by alias); 1 Jun 2005 00:23:10 -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 21208 invoked by uid 22791); 1 Jun 2005 00:22:53 -0000 Received: from vinc17.net4.nerim.net (HELO ay.vinc17.org) (62.212.121.106) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 01 Jun 2005 00:22:53 +0000 Received: from lefevre by ay.vinc17.org with local (Exim 4.50) id 1DdH0U-0005pJ-5T; Wed, 01 Jun 2005 02:22:50 +0200 Date: Wed, 01 Jun 2005 00:23:00 -0000 From: Vincent Lefevre To: gcc@gcc.gnu.org Subject: Re: What is wrong with Bugzilla? [Was: Re: GCC and Floating-Point] Message-ID: <20050601002249.GK3541@ay.vinc17.org> Mail-Followup-To: gcc@gcc.gnu.org References: <20050531124837.GT3541@ay.vinc17.org> <20050531134304.GV3541@ay.vinc17.org> <20050531171400.GY3541@ay.vinc17.org> <20050531195816.GE3541@ay.vinc17.org> <20050531224258.GJ3541@ay.vinc17.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.9-vl-20050401i X-SW-Source: 2005-06/txt/msg00000.txt.bz2 On 2005-06-01 00:58:25 +0200, Andreas Schwab wrote: > You are mistaken. No, I don't see any problem. > #include > #include > > long double one = 1.0; > long double one_plus_eps; > > int > main (void) > { > long double one_plus_eps; > > one_plus_eps = one + LDBL_EPSILON; > assert (one != one_plus_eps); > return 0; > } I don't know how the standard should be interpreted (see below), but if your program fails, this means that either your program is buggy or the C implemention is buggy. The standard says for LDBL_EPSILON: "the difference between 1 and the least value greater than 1 that is representable in the given floating point type, b^(1-p)". One may decide that p = 64. The processor will round to double precision, but that's OK since the C standard doesn't require correct rounding (the accuracy is implementation-defined, as said in #4). Your program will fail because it is not portable: you made some assumptions about the accuracy. One may decide that p = 53. I think this is better. Your program will work (unless LDBL_EPSILON has a value assuming that p = 64, but this would mean that your C implementation is buggy). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / SPACES project at LORIA