• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
long double on 64 bit Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

long double on 64 bit Intel


  • Subject: long double on 64 bit Intel
  • From: Jeffrey Stopple <email@hidden>
  • Date: Wed, 8 Aug 2007 09:01:10 -0700

Thanks to everyone who answered my previous questions. I'm using the 64 bit architecture to have access to the GMP library, and 'it is not possible to configure GMP to run in 32-bit mode on a 64-bit Intel processor (Xeon) at this time.' see: http://images.apple.com/acg/ pdf/MP_Floating_Point_20070313.pdf

According to http://developer.apple.com/documentation/MacOSX/ Conceptual/universal_binary/universal_binary_diffs/ chapter_3_section_8.html
a long double is 128 bits on Intel Macs, but only 80 bits are significant. Does this mean 80 bits of mantissa, or does that include the exponent, and if so how is it divided up between mantissa and exponent? I wrote the following code as an experiment:


#include <stdio.h>
#include <float.h>

int main()
{
  printf("%d\n",sizeof(void*));
  printf("%d\n",sizeof(long));
  printf("%d\n",sizeof(double));
  printf("%d\n",sizeof(long double));
  printf("%g\n",LDBL_MIN);
  printf("%g\n",LDBL_MAX);

  long double x= 0.12345678901234567890123456789L;
  printf("ldfloat %.30Le \n",x);

  return 0;
}

Here's the build log and output:

Building target “wtf” of project “wtf” with configuration “Debug”

Checking Dependencies
CompileC build/wtf.build/Debug/wtf.build/Objects-normal/x86_64/main.o
/Users/stopple/Desktop/wtf/main.c normal x86_64 c
com.apple.compilers.gcc.4_0
cd /Users/stopple/Desktop/wtf
/usr/bin/gcc-4.0 -x c -arch x86_64 -pipe -std=gnu99 -Wno-trigraphs
-fpascal-strings -fasm-blocks -g -O0 -Wreturn-type -Wunused-variable
-fmessage-length=0 -fvisibility=hidden -mfix-and-continue
-mmacosx-version-min=10.4
-I/Users/stopple/Desktop/wtf/build/wtf.build/Debug/wtf.build/wtf.hmap
-F/Users/stopple/Desktop/wtf/build/Debug
-I/Users/stopple/Desktop/wtf/build/Debug/include
-I/Users/stopple/Desktop/wtf/build/wtf.build/Debug/wtf.build/ DerivedSources
-isysroot /Developer/SDKs/MacOSX10.4u.sdk -c
/Users/stopple/Desktop/wtf/main.c -o
/Users/stopple/Desktop/wtf/build/wtf.build/Debug/wtf.build/Objects- normal/x86_64/main.o


Ld /Users/stopple/Desktop/wtf/build/Debug/wtf normal x86_64
cd /Users/stopple/Desktop/wtf
/usr/bin/gcc-4.0 -o /Users/stopple/Desktop/wtf/build/Debug/wtf
-L/Users/stopple/Desktop/wtf/build/Debug
-F/Users/stopple/Desktop/wtf/build/Debug -filelist
/Users/stopple/Desktop/wtf/build/wtf.build/Debug/wtf.build/Objects- normal/x86_64/wtf.LinkFileList
-arch x86_64 -Wl,-Y,1455 -mmacosx-version-min=10.4 -isysroot
/Developer/SDKs/MacOSX10.4u.sdk


[Session started at 2007-08-08 08:50:48 -0700.]
8
8
8
16
0
0
ldfloat 1.234567890123456789013218007356e-01

wtf has exited with status 0.

It looks like there's only about 21 decimal digits, whereas 80 bits should give about 24 decimal digits? On my G5, a similar experiment:

#include <stdio.h>
#include <float.h>

int main()
{
  printf("%d\n",sizeof(void*));
  printf("%d\n",sizeof(long));
  printf("%d\n",sizeof(double));
  printf("%d\n",sizeof(long double));
  printf("%g\n",LDBL_MIN);
  printf("%g\n",LDBL_MAX);

  long double x= 0.123456789012345678901234567890L;
  printf("ldfloat %.30Le \n",x);

  return 0;
}

Building target “wtf” of project “wtf” with configuration “Debug”


Checking Dependencies
CompileC build/wtf.build/Debug/wtf.build/Objects-normal/ppc64/main.o
/Users/stopple/Desktop/ccode/wtf/main.c normal ppc64 c
com.apple.compilers.gcc.4_0
cd /Users/stopple/Desktop/ccode/wtf
/usr/bin/gcc-4.0 -x c -arch ppc64 -pipe -std=gnu99 -Wno-trigraphs
-fpascal-strings -faltivec -fasm-blocks -gfull -O3 -Wreturn-type
-Wunused-variable -fmessage-length=0 -mtune=G5 -mpowerpc64
-fvisibility=hidden -mfix-and-continue -mmacosx-version-min=10.4
-I/Users/stopple/Desktop/ccode/wtf/build/wtf.build/Debug/wtf.build/ wtf.hmap
-F/Users/stopple/Desktop/ccode/wtf/build/Debug
-I/Users/stopple/Desktop/ccode/wtf/build/Debug/include
-I/Users/stopple/Desktop/ccode/wtf/build/wtf.build/Debug/wtf.build/ DerivedSources
-ppc64 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -c
/Users/stopple/Desktop/ccode/wtf/main.c -o
/Users/stopple/Desktop/ccode/wtf/build/wtf.build/Debug/wtf.build/ Objects-normal/ppc64/main.o
powerpc-apple-darwin8-gcc-4.0.1: unrecognized option '-ppc64'


Ld /Users/stopple/Desktop/ccode/wtf/build/Debug/wtf normal ppc64
cd /Users/stopple/Desktop/ccode/wtf
/usr/bin/gcc-4.0 -o /Users/stopple/Desktop/ccode/wtf/build/Debug/ wtf
-L/Users/stopple/Desktop/ccode/wtf/build/Debug
-F/Users/stopple/Desktop/ccode/wtf/build/Debug -filelist
/Users/stopple/Desktop/ccode/wtf/build/wtf.build/Debug/wtf.build/ Objects-normal/ppc64/wtf.LinkFileList
-arch ppc64 -Wl,-Y,1455 -mmacosx-version-min=10.4 -isysroot
/Developer/SDKs/MacOSX10.4u.sdk


[Session started at 2007-08-08 08:34:37 -0700.]
8
8
8
16
2.00417e-292
1.79769e+308
ldfloat 1.234567890123456789012345678900e-01

wtf has exited with status 0.

It looks like about 30 decimal digits, which is what I recall the documentation described (I can no longer find it on the apple site,)

I can live with this if it is correct, but the results for LDBL_MIN and LDBL_MAX on the Intel version seem suspicious.

Jeff


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: long double on 64 bit Intel
      • From: Jonas Maebe <email@hidden>
  • Prev by Date: Re: How packages are recognized...
  • Next by Date: Re: How packages are recognized...
  • Previous by thread: Re: Seeking Preprocessor macro clarification
  • Next by thread: Re: long double on 64 bit Intel
  • Index(es):
    • Date
    • Thread