#include %26lt;stdlib.h%26gt;
#include %26lt;iostream%26gt;
using namespace std;
#include %26lt;string%26gt;
#include %26lt;fstream%26gt;
#include %26lt;math.h%26gt;
#include %26lt;time.h%26gt;
void main()
{
double ktemp=987654321.123456789;
cout %26lt;%26lt; ktemp %26lt;%26lt; endl;
}
it will display 9.87654e+008, and if I divide it by 1000 it shows 987654. this is a huge problem since im dealing with GIS coordinates and I NEED the full value of the number, i get the same problem when writing these values to a file, which is my ultimate goal
I am using c++ with doubles. say the number is 987654321, it changes it to 987650000. anyone know why? fix?
try
int main(int argc, char* argv[])
{
double ktemp=987654321.123456789;
cout.precision(20); // this sets the precision of the output to 20 places.
cout %26lt;%26lt; ktemp %26lt;%26lt; endl;
cout %26lt;%26lt; ktemp/1000. %26lt;%26lt; endl;
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment