Re: [Dev-C++] floating point numbers
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Verne H. B. <ve...@sy...> - 2005-08-14 16:03:42
|
Along with the correction suggested and reason for wrong answer you think you
got don't forget to use this before return.
system("PAUSE");
return 0;
Verne
Hello, I am new to programming and to c++ and Dev-CPP. I have been
experimenting with numbers and can't figure this one out. Here is the
code the I am using:
#include<iostream>
using namespace std;
int main ()
{
int a;
float b;
double c;
long double d;
cout << " Enter a number: ";
cin >> d;
c=d;
b=d;
a=d;
cout << d << endl << c << endl << b << endl << a << endl;
return 0;
}
Here is the result with the number 123456789.123456789:
1.23457e+008
1.23457e+008
1.23457e+008
123456789
Now from what I have read, a long double should be good up to 19
digits, a long up to 15, and a float up to 7. Why does the long double
return 1.23457e+008, instead of the entered value of
123456789.123456789, which is only 18 digits long?
--
Paul Lane
KC9EYE
-----------------------------------------------------------------------------
"Life after all, is a fatal disease, and the mortality rate
for humans, at the end of the day is 100%."
K.C. Cole
----------------------------------------------------------------------------
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|