Tuesday, January 15, 2008

Problems with Double Extended Precision on YDL for the PS3

My gcc compiler version is gcc version 4.1.1 20060525 (Yellow Dog 4.1.1-1).

This isn't the best C++ program (modified from PSC):

#include iostream

float FloatMachineEps();
double DoubleMachineEps();
long double LongDoubleMachineEps();
int main(int * argc, char ** argv[]){
float fep;
double dep;
long double ldep;
using namespace std;
fep = FloatMachineEps();
dep = DoubleMachineEps();
ldep = LongDoubleMachineEps();
cout << "Machine epsilon for single precision is: ";
cout << fep << endl;

cout << "Machine epsilon for double precision is: ";
cout << dep << endl;

cout << "Machine epsilon for double extended precision is: ";
cout << ldep << endl;
}
float FloatMachineEps(){
float fmachine_e, ftest;
fmachine_e = 1.0;

ftest = 1.0 + fmachine_e;
while (1.0 != ftest){
fmachine_e = fmachine_e/2.0;
ftest = 1.0 + fmachine_e;
}
return fmachine_e;
}

double DoubleMachineEps(){
double dmachine_e, dtest;
dmachine_e = 1.0;

dtest = 1.0 + dmachine_e;
while (1.0 != dtest){
dmachine_e = dmachine_e/2.0;
dtest = 1.0 + dmachine_e;
}
return dmachine_e;
}

long double LongDoubleMachineEps(){
long double ldmachine_e, ldtest;
ldmachine_e = 1.0;

ldtest = 1.0 + ldmachine_e;
while (1.0 != ldtest){
ldmachine_e = ldmachine_e/2.0;
ldtest = 1.0 + ldmachine_e;
}
return ldmachine_e;
}

but when I compile and run it on my old 32-bit AMD uniprocessor I get:

./machine_zero
Machine epsilon for single precision is: 5.96046e-08
Machine epsilon for double precision is: 1.11022e-16
Machine epsilon for double extended precision is: 5.42101e-20

versus

./machine_zero
Machine epsilon for single precision is: 5.96046e-08
Machine epsilon for double precision is: 1.11022e-16
Machine epsilon for double extended precision is: 0

on my PS3 running Yellow Dog Linux. Uh-oh!

Labels:


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?