From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11553 invoked by alias); 27 Sep 2011 18:27:18 -0000 Received: (qmail 11544 invoked by uid 22791); 27 Sep 2011 18:27:17 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,TW_BJ,TW_CX,TW_DC,TW_GX X-Spam-Check-By: sourceware.org Received: from moene.org (HELO moene.org) (82.95.66.103) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Sep 2011 18:27:03 +0000 Received: from localhost ([::1]) by moene.org with esmtp (Exim 4.76) (envelope-from ) id 1R8cMt-0007dn-SC; Tue, 27 Sep 2011 20:26:59 +0200 Message-ID: <4E821573.1070206@moene.org> Date: Wed, 28 Sep 2011 00:41:00 -0000 From: Toon Moene User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 To: Ian Lance Taylor CC: Michael Veksler , gcc-help@gcc.gnu.org Subject: Re: sizeof(long double) vs. std::numeric_limits and x86-64 vs x86 References: <4E80F88F.2050608@tx.technion.ac.il> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 X-SW-Source: 2011-09/txt/msg00225.txt.bz2 On 09/27/2011 12:46 AM, Ian Lance Taylor wrote: > Michael Veksler writes: > >> I wanted to check how many bits long double takes. So I checked >> sizeof(long double) which, naturally, may account for padding. On >> x86-64 it takes 16 bytes and only 12 on x86, a difference of 4 >> bytes. This supported my hope that on x86-64 we would have "long >> double"= |__float128|. > > Alas, no. On x86_64 long double is an 80-bit floating point number, > just as on 32-bit x86. The size is 16 bytes because the x86_64 prefers > to align large values to 8-byte boundaries. > > gcc works this way because the 80-bit floating point format is supported > directly in hardware, unlike the 128-bit format. But if you really long for 16 byte floating point computations, you could always switch to Fortran: $ cat a.f REAL*16 A CHARACTER*80 :: LINE = ' 394728372973498274982794792.342987E3798' READ(LINE, *) A PRINT*,A END $ gfortran a.f $ ./a.out 3.94728372973498274982794792342987006E+3824 $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.1-4' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/x86_64-linux-gnu --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.1 (Debian 4.6.1-4) :-) -- Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290 Saturnushof 14, 3738 XG Maartensdijk, The Netherlands At home: http://moene.org/~toon/; weather: http://moene.org/~hirlam/ Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news