Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xlc accuracy issue

Status
Not open for further replies.

radhanitt

Programmer
Joined
May 5, 2007
Messages
5
Location
US
Hi,

#include <stdio.h>
int main()
{
double t=1.6e55;
printf("%f\n",t);
printf("%f\n",1.6e55);
printf("%f\n",1.6e54);
printf("%f\n",1.6e53);
printf("%f\n",1.6e52);
printf("%f\n",1.6e42);
printf("%f\n",1.6e30);
printf("%f\n",1.6e29);
}

% xlc exp.c -g -o aaix
% ./aaix
16000000000000001252664646473500000000000000000000000000.000000
16000000000000001252664646473500000000000000000000000000.000000
1599999999999999989153517878980000000000000000000000000.000000
159999999999999998915351787898000000000000000000000000.000000
15999999999999999891535178789800000000000000000000000.000000
1600000000000000009920138320650000000000000.000000
1599999999999999862930413715460.000000
159999999999999993329915789312.000000

But in linux:
% gcc exp.c -m32 -o amd
% ./amd
16000000000000001252664646473539901476885764798177869824.000000
16000000000000001252664646473539901476885764798177869824.000000
1599999999999999989153517878978604762338733507110502400.000000
159999999999999998915351787897860476233873350711050240.000000
15999999999999999891535178789786047623387335071105024.000000
1600000000000000009920138320652453111922688.000000
1599999999999999862930413715456.000000
159999999999999993329915789312.000000

How do I match aix results with that of linux? What is the problem here?
 
hi,

"%f" is thing for "engineer", IT people have to use it with care.

"Engineer"ing speaking, results are equals !

bye
 
Thanks Victor for your response. But my question is why is there a difference?
 
Does this make a difference?

[tt]#include <stdio.h>
int main()
{
double t=(double)1.6e55;
printf("%f\n",t);
printf("%f\n",(double)1.6e55);
printf("%f\n",(double)1.6e54);
printf("%f\n",(double)1.6e53);
printf("%f\n",(double)1.6e52);
printf("%f\n",(double)1.6e42);
printf("%f\n",(double)1.6e30);
printf("%f\n",(double)1.6e29);
}[/tt]



HTH,

p5wizard
 
Thank you for the suggestion! No it doesn't! Result is same!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top