public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Toon Moene <toon@moene.org>
To: Ian Lance Taylor <iant@google.com>
Cc: Michael Veksler <mveksler@techunix.technion.ac.il>,
	 gcc-help@gcc.gnu.org
Subject: Re: sizeof(long double) vs. std::numeric_limits and x86-64 vs x86
Date: Wed, 28 Sep 2011 00:41:00 -0000	[thread overview]
Message-ID: <4E821573.1070206@moene.org> (raw)
In-Reply-To: <mcrmxdqgbvq.fsf@coign.corp.google.com>

On 09/27/2011 12:46 AM, Ian Lance Taylor wrote:

> Michael Veksler<mveksler@tx.technion.ac.il>  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

      parent reply	other threads:[~2011-09-27 18:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27  5:09 Michael Veksler
2011-09-27  5:12 ` Ian Lance Taylor
2011-09-27 18:27   ` Michael Veksler
2011-09-28  0:41   ` Toon Moene [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E821573.1070206@moene.org \
    --to=toon@moene.org \
    --cc=gcc-help@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=mveksler@techunix.technion.ac.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).