# printing large decimal numbers

• 03-20-2002
Isometric
printing large decimal numbers
How do you print decimal numbers that are have more then 6 didgets? I'm writing a small prog to find the square root of 50 but the decimals are large and it only prints out 6 spots. any idea what could remedy the situation? (Code is below)
Code:

```#include [itex] #include <iostream> double i = (double)sqrt(50.0) ; main (){ cout << "square root of 50 :" << i ; }```
• 03-20-2002
Sorensen
You could try -

Code:

```#include <cmath> #include <iostream> #include <iomanip> using namespace std; int main (){         double i = sqrt(50.0) ;         cout << setprecision(10) << "square root of 50 :" << i ;         return 0; }```
• 03-20-2002
Colin
#include <math.h>
#include <iostream.h>
#include<conio.h>
float i = (float)sqrt(50.0) ;

main (){
cout << "square root of 50 :" << i ;
getche();
}
This gives me a result of 7.07107
Is that what you are looking for?
-Colin
• 03-20-2002
biosx
Sorensen has the right idea. I would add the following:

Code:

```#include <cmath> #include <iostream> #include <iomanip> using namespace std; int main () {   double i = sqrt(50.0) ;   cout << setprecision(10) << setiosflags(ios::fixed | ios::showpoint) << "square root of 50: " << i ;   return 0; }```
• 03-20-2002
Isometric
Quote:

Originally posted by biosx

Code:

```  cout << setprecision(10) << setiosflags(ios::fixed | ios::showpoint) << "square root of 50: " << i ; }```

Please explain this line? what is setprecision and setiosflags?

Also Colin that is what I'm getting now but there is really alot or didgets. That squared is 50.0000309449. The real number will be 5 squareroots of 2 but I want a decimal number for it.
• 03-20-2002
Unregistered
Download a package called NTL. It is a C++ package that allows abitrary precision math. You can find it through any search engine.