From owner-freebsd-toolchain@FreeBSD.ORG Tue Sep 18 14:24:46 2012 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 27ABF106564A; Tue, 18 Sep 2012 14:24:46 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay010.isp.belgacom.be (mailrelay010.isp.belgacom.be [195.238.6.177]) by mx1.freebsd.org (Postfix) with ESMTP id 7137F8FC0A; Tue, 18 Sep 2012 14:24:45 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAFADyDWFBbsUA+/2dsb2JhbABFhgm2MoEJgiABAQQBIzMiAQULCxgJFgsCAgkDAgECASceBg0BBQIBAYd2CqcjkxuLG4VegRIDjmmBIJV7gmg Received: from 62.64-177-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.177.64.62]) by relay.skynet.be with ESMTP; 18 Sep 2012 16:23:36 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.5/8.14.5) with ESMTP id q8IENZWe003077; Tue, 18 Sep 2012 16:23:35 +0200 (CEST) (envelope-from tijl@coosemans.org) Message-ID: <505883E3.3050103@coosemans.org> Date: Tue, 18 Sep 2012 16:23:31 +0200 From: Tijl Coosemans User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:14.0) Gecko/20120804 Thunderbird/14.0 MIME-Version: 1.0 To: Mehmet Erol Sanliturk 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> In-Reply-To: X-Enigmail-Version: 1.4.2 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1DF7D13A799809AA81AB7E12" Cc: toolchain@freebsd.org, current@freebsd.org 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: Tue, 18 Sep 2012 14:24:46 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1DF7D13A799809AA81AB7E12 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 15-09-2012 17:39, Mehmet Erol Sanliturk wrote: > On Sat, Sep 15, 2012 at 7:30 AM, Tijl Coosemans wr= ote:=20 >> 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.=20 >=20 > 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 >=20 > clang version 3.0 (tags/RELEASE_30/final) > Target: x86_64-redhat-linux-gnu > Thread model: posix >=20 >=20 > Output of the initial program is the following : >=20 > #include > #include > #include >=20 > int > main( int argc, char **argv ) { > double d =3D strtod( argv[ 1 ], NULL ); >=20 > printf( " cos : %e\n", ( double ) cos( d )); > printf( "cosf : %e\n", ( double ) cosf( d )); > printf( "cosl : %e\n", ( double ) cosl( d )); > return( 0 ); > } >=20 >=20 > cos : 2.814722e-01 > cosf : -9.629173e-02 > cosl : 7.738403e-01 This is probably because SSE instructions are used on amd64. > Output of the following program is different : The reason is that... > #include > #include > #include >=20 > int > main( int argc, char **argv ) { > double d ; > double two_pi ; > double f ; > double v ; >=20 > two_pi =3D 2 * 3.14159265358979323846 ; > d =3D strtod( argv[ 1 ], NULL ); >=20 > f =3D floor ( d / two_pi ) ; > v =3D d - f * two_pi ; =2E..this is a poor way to compute a remainder. Try to use fmod() or remainder() instead. > printf( " given : %e\n", ( double ) d ); > printf( " multiplier : %e\n", ( double ) f ); > printf( "reduced : %e\n", ( double ) v ); >=20 >=20 > 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 )); >=20 >=20 > 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 )); >=20 >=20 > return( 0 ); > } >=20 >=20 > given : 1.234568e+20 > multiplier : 1.964876e+19 > reduced : 1.638400e+04 >=20 >=20 > cos ( 1.234568e+20 ) : 2.814722e-01 > cosf ( 1.234568e+20 ) : -9.629173e-02 > cosl ( 1.234568e+20 ) : 7.738403e-01 >=20 > cos ( 1.638400e+04 ) : -8.285342e-01 > cosf ( 1.638400e+04 ) : -8.285342e-01 > cosl ( 1.638400e+04 ) : -8.285342e-01 --------------enig1DF7D13A799809AA81AB7E12 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iF4EAREIAAYFAlBYg+cACgkQfoCS2CCgtitqygD/V7Qv07Ni2tZG6xJZx4zSwVuq SmtXliYN5IKZAlUnuaUA/jbZ4TqcvzdfLR059dZUqMMaS8udmcs10xtFVcIWmlRV =+OaS -----END PGP SIGNATURE----- --------------enig1DF7D13A799809AA81AB7E12--