• 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 Calculation on Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Long Double Calculation on Intel


  • Subject: Long Double Calculation on Intel
  • From: Richard Somers <email@hidden>
  • Date: Tue, 9 Oct 2007 10:00:17 -0600

Below is a small program which calculates the cosine of 45 degrees in double and long double precision. The result should be 0.707...

It works fine on PowerPC but the Intel long double produces garbage. Does anyone know what is happening here?

I know the PowerPC long double precision is 128 bits and the Intel long double precision is 80 bits. But it still should work.

#include <stdio.h>
#include <math.h>

int main ()
{
    double result1 = cos(45.0 * M_PI / 180.0);
    printf("cos 45 degrees .14e\n", result1);

    long double result2 = cosl(45.0 * M_PI / 180.0);
    printf("cosl 45 degrees .14e\n", result2);

    return 0;
}

PowerPC Output
cos 45 degrees 7.07106781186547e-01
cosl 45 degrees 7.07106781186548e-01

Intel Output
cos 45 degrees 7.07106781186548e-01
cosl 45 degrees -2.73410411748968e-53

Regards, Richard
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Long Double Calculation on Intel
      • From: Paul Goracke <email@hidden>
  • Prev by Date: Re: Getting Carbon Volume Mount Events in a Cocoa (Core Foundation) process
  • Next by Date: Re: Long Double Calculation on Intel
  • Previous by thread: Re: multicasting and distributed objects
  • Next by thread: Re: Long Double Calculation on Intel
  • Index(es):
    • Date
    • Thread