Hi,
I have this program in C++ and I am struggling to understand as to why I am not able to store a value in an integer declared in the program as double within the acceptable range of 2.2e-308 to 1.8e308. Here this page also says so in a table:
http://www.samspublishing.com/articles/article.asp?p=26933&rl=1
As far as I understand a double in C++ should be able to store a value of more than 308 digits right? Please correct me if I am wrong as I am new to C++ programming. I am on Fedora Core 5 32+ bit OS. Can any one please help me with this? Here is the code: Thanks a lot.
#include <iostream>
//Testing the actual range of a double integer........
int main()
{
using namespace std;
double microsoft=4294967295;
double intel=55555557777777770;
double total=microsoft+intel;
cout<<"The total is: "<<total<<" dollars\n";
return 0;
}
Error:
[root@localhost Prac]# g++ -o exp13 exp13.cpp
exp13.cpp:9: warning: this decimal constant is unsigned only in ISO C90
exp13.cpp:10: error: integer constant is too large for ‘long’ type
[root@localhost Prac]# ./exp13
The total is: 4.35052e+09 dollars