multiply big doubles

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

multiply big doubles

Post by yiuyuho »

I tried this on my computer:

cout<<1999999999.0*1999999999.0<<endl;

and get runtime error,, why is this happening? I am using MS-windows
junbin
Experienced poster
Posts: 174
Joined: Mon Dec 08, 2003 10:41 am

Post by junbin »

[cpp]
#include <stdio.h>
int main(void) {
printf("%llf", 1999999999.0*1999999999.0);
return 0;
}
[/cpp]

and

[cpp]
#include <iostream>

using namespace std;

int main(void) {
cout<<1999999999.0*1999999999.0<<endl;
return 0;
}
[/cpp]

both works with Visual Studio
yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

Post by yiuyuho »

I see, I was using #include <iostream.h>, the old stuff and get runtime error, probably the new iostream package fixed it.

Thank You very much for your help!!
Post Reply

Return to “C++”