From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31881 invoked by alias); 20 Sep 2018 16:12:08 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 31862 invoked by uid 89); 20 Sep 2018 16:12:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: joooj.vinc17.net Received: from joooj.vinc17.net (HELO joooj.vinc17.net) (155.133.131.76) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Sep 2018 16:12:06 +0000 Received: by joooj.vinc17.net (Postfix, from userid 1000) id 384A71407; Thu, 20 Sep 2018 18:12:04 +0200 (CEST) Date: Thu, 20 Sep 2018 16:12:00 -0000 From: Vincent Lefevre To: Liu Hao , Andrew Haley , Neha Gowda , gcc-help@gcc.gnu.org Subject: Re: Should rand() return a RAND_MAX value for 32 bit target? Message-ID: <20180920161204.GB304@joooj.vinc17.net> Mail-Followup-To: Liu Hao , Andrew Haley , Neha Gowda , gcc-help@gcc.gnu.org References: <9194d2a2-74c0-2d51-c4b5-433d2744cd43@redhat.com> <20180920144238.GB24856@cventin.lip.ens-lyon.fr> <20180920150550.GA4852@cventin.lip.ens-lyon.fr> <590e8205.c4aa.165f7924592.Coremail.lh_mouse@126.com> <20180920155829.GA304@joooj.vinc17.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180920155829.GA304@joooj.vinc17.net> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.10.1+96 (4350694b) vl-108074 (2018-09-18) X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00066.txt.bz2 On 2018-09-20 17:58:30 +0200, Vincent Lefevre wrote: > On 2018-09-20 23:21:23 +0800, Liu Hao wrote: > > `2147483647` is an integer constant. This rule only describes floating > > constants, so it does not apply. > > Actually the fact that it is a constant doesn't matter, but... > > > According to '6.3.1.8 Usual arithmetic conversions', here `2147483647` > > is converted to a value having type `float`, which is then compared with > > `f` using the internal `long double` type. > > The conversion of the int needs to be done with the precision and > range of long double since this is neither an assignment nor a cast. Similarly, for float a, b; double c; (a + b) + c; I would expect the result of a + b to be kept in long double instead of being converted to double due to the operand c. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)