From owner-freebsd-toolchain@FreeBSD.ORG Sat Sep 15 15:39:24 2012 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24C94106568E; Sat, 15 Sep 2012 15:39:24 +0000 (UTC) (envelope-from m.e.sanliturk@gmail.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 89D468FC12; Sat, 15 Sep 2012 15:39:23 +0000 (UTC) Received: by obbun3 with SMTP id un3so9380070obb.13 for ; Sat, 15 Sep 2012 08:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1tsqKuiyLYsZ3EZ1f3p88GXeFAsnhKJyJ5i1mJOOkBw=; b=y7O+TKxGTRgsH/uVX+JwdNG7NML4tiuisE5NKGSfxpBvSXSnTtnlwlJgBEUE6FWe3D RxPUTywo1NnQeTKngppXEcP862gyQe6+nPabUAyCvCqEY4kyXsNYyUQtR9qmbLpTWWye 0pss5V4QPkTXRkrWinrpoZ8ZpK5ciQPQ1SVQSAVguJhyOMewUscLQfi044rnUf6vIf0/ XKIOkckEyEcteTG4f17Y5NUvkkdsRso9RnhWzitYs4crxjSRsKiITB5t4Gpa/Qt4Cna3 uoyVAV5X6OoPsJuybs4dN26PjweLy9mVhBR+0qCZVUaM1ubr65FeiBy039LRFClqU08Y aH5w== MIME-Version: 1.0 Received: by 10.182.76.194 with SMTP id m2mr7438676obw.27.1347723562837; Sat, 15 Sep 2012 08:39:22 -0700 (PDT) Received: by 10.182.141.66 with HTTP; Sat, 15 Sep 2012 08:39:22 -0700 (PDT) In-Reply-To: <505490FB.2000807@coosemans.org> References: <504F5101.8090906@FreeBSD.org> <505101C3.70203@freebsd.org> <20120913020833.GA8255@troutmask.apl.washington.edu> <1347550332.1110.108.camel@revolution.hippie.lan> <20120913161024.GA13846@troutmask.apl.washington.edu> <20120914202319.GB5244@lor.one-eyed-alien.net> <20120915001808.GA70215@troutmask.apl.washington.edu> <20120915010600.GA70426@troutmask.apl.washington.edu> <20120915124809.GA10939@freebsd.org> <50548736.9030203@coosemans.org> <20120915140933.GA17801@freebsd.org> <505490FB.2000807@coosemans.org> Date: Sat, 15 Sep 2012 08:39:22 -0700 Message-ID: From: Mehmet Erol Sanliturk To: Tijl Coosemans Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Ian Lepore , current@freebsd.org, Dimitry Andric , toolchain@freebsd.org, Steve Kargl Subject: Re: Clang as default compiler November 4th X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2012 15:39:24 -0000 On Sat, Sep 15, 2012 at 7:30 AM, Tijl Coosemans wrote: > On 15-09-2012 16:09, Roman Divacky wrote: > > Is this correct? > > > > lev ~$ ./cos 1.23456789e20 > > 6.031937e-01 > > -9.629173e-02 > > 2.814722e-01 > > Yes, that's what the libm call returns. > > Linux z 3.5.3-1.fc17.x86_64 #1 SMP Wed Aug 29 18:46:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux clang version 3.0 (tags/RELEASE_30/final) Target: x86_64-redhat-linux-gnu Thread model: posix Output of the initial program is the following : #include #include #include int main( int argc, char **argv ) { double d = strtod( argv[ 1 ], NULL ); printf( " cos : %e\n", ( double ) cos( d )); printf( "cosf : %e\n", ( double ) cosf( d )); printf( "cosl : %e\n", ( double ) cosl( d )); return( 0 ); } cos : 2.814722e-01 cosf : -9.629173e-02 cosl : 7.738403e-01 ....................................................... Output of the following program is different : #include #include #include int main( int argc, char **argv ) { double d ; double two_pi ; double f ; double v ; two_pi = 2 * 3.14159265358979323846 ; d = strtod( argv[ 1 ], NULL ); f = floor ( d / two_pi ) ; v = d - f * two_pi ; printf( " given : %e\n", ( double ) d ); printf( " multiplier : %e\n", ( double ) f ); printf( "reduced : %e\n", ( double ) v ); printf( " cos ( %e ) : %e\n", d , ( double ) cos( d )); printf( "cosf ( %e ) : %e\n", d , ( double ) cosf( d )); printf( "cosl ( %e ) : %e\n", d , ( double ) cosl( d )); printf( " cos ( %e ) : %e\n", v , ( double ) cos( v )); printf( "cosf ( %e ) : %e\n", v , ( double ) cosf( v )); printf( "cosl ( %e ) : %e\n", v , ( double ) cosl( v )); return( 0 ); } given : 1.234568e+20 multiplier : 1.964876e+19 reduced : 1.638400e+04 cos ( 1.234568e+20 ) : 2.814722e-01 cosf ( 1.234568e+20 ) : -9.629173e-02 cosl ( 1.234568e+20 ) : 7.738403e-01 cos ( 1.638400e+04 ) : -8.285342e-01 cosf ( 1.638400e+04 ) : -8.285342e-01 cosl ( 1.638400e+04 ) : -8.285342e-01 ....................................................... Reduction of argument once more did NOT change results : #include #include #include int main( int argc, char **argv ) { double d ; double two_pi ; double f ; double v ; double g ; double w ; two_pi = 2 * 3.14159265358979323846 ; d = strtod( argv[ 1 ], NULL ); printf( " given : %e\n", ( double ) d ); printf( " cos ( %e ) : %e\n", d , ( double ) cos( d )); printf( "cosf ( %e ) : %e\n", d , ( double ) cosf( d )); printf( "cosl ( %e ) : %e\n", d , ( double ) cosl( d )); f = floor ( d / two_pi ) ; v = d - f * two_pi ; printf( "multiplier : %e\n", ( double ) f ); printf( " reduced : %e\n", ( double ) v ); printf( " cos ( %e ) : %e\n", v , ( double ) cos( v )); printf( "cosf ( %e ) : %e\n", v , ( double ) cosf( v )); printf( "cosl ( %e ) : %e\n", v , ( double ) cosl( v )); g = floor ( v / two_pi ) ; w = v - g * two_pi ; printf( "multiplier : %e\n", ( double ) g ); printf( " reduced : %e\n", ( double ) w ); printf( " cos ( %e ) : %e\n", w , ( double ) cos( w )); printf( "cosf ( %e ) : %e\n", w , ( double ) cosf( w )); printf( "cosl ( %e ) : %e\n", w , ( double ) cosl( w )); return( 0 ); } given : 1.234568e+20 cos ( 1.234568e+20 ) : 2.814722e-01 cosf ( 1.234568e+20 ) : -9.629173e-02 cosl ( 1.234568e+20 ) : 7.738403e-01 multiplier : 1.964876e+19 reduced : 1.638400e+04 cos ( 1.638400e+04 ) : -8.285342e-01 cosf ( 1.638400e+04 ) : -8.285342e-01 cosl ( 1.638400e+04 ) : -8.285342e-01 multiplier : 2.607000e+03 reduced : 3.735904e+00 cos ( 3.735904e+00 ) : -8.285342e-01 cosf ( 3.735904e+00 ) : -8.285342e-01 cosl ( 3.735904e+00 ) : -8.285342e-01 ....................................................... Thank you very much . Mehmet Erol Sanliturk