Long Double Calculation on Intel

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 %16.14e\n", result1);
long double result2 = cosl(45.0 * M_PI / 180.0);
printf("cosl 45 degrees %16.14e\n", result2);
return 0;
}
PowerPC Output
cos 45 degrees 7.07106781186547e01
cosl 45 degrees 7.07106781186548e01
Intel Output
cos 45 degrees 7.07106781186548e01
cosl 45 degrees 2.73410411748968e53
Regards, Richard 
On Oct 9, 2007, at 9:00 AM, Richard Somers wrote:
> 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?
The values of result1 and result2 are correct; the output you're
seeing isn't, because you're not using the correct printf specifier
for long double. Change the second printf to:
printf("cosl 45 degrees %16.14Le\n", result2);
(note the 'Le' instead of just 'e').
pg 
Thank you so much Paul! That fixed the problem.
Second related question. Does anyone know how to get 128 bit floating
point precision on Intel like what is available on PowerPC?
Richard
On Oct 9, 2007, at 10:52 AM, Paul Goracke wrote:
> The values of result1 and result2 are correct; the output you're
> seeing isn't, because you're not using the correct printf specifier
> for long double. Change the second printf to:
>
> printf("cosl 45 degrees %16.14Le\n", result2);
>
> (note the 'Le' instead of just 'e').
>

I found the answer to my own question. Apple's "Advanced Computation
Group" recently issued a technical paper on the subject titled
"Multiprecision Floatingpoint Arithmetic on Apple Systems" dated
February 2007.
Richard
On Oct 9, 2007, at 1:43 PM, Richard Somers wrote:
> Second related question. Does anyone know how to get 128 bit
> floating point precision on Intel like what is available on PowerPC?
>