# Thread: number ouput problem...

1. ## number ouput problem...

Hello everyone, heres my problem...

When I enter values into my console app too big, it converts my numbers to things like 9.9e+010, thats for 99000000000. My qiestion is, is theres a variable type that will display that many digits? Or is it not even a matter of variable type? Im currently using long double. Thanks

edit: heres the code

Code:
```//ResistorCalculator.cpp

#include <iostream.h> using namespace std;
#include <math.h>
#include <conio.h>

int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
long double color1, color2, color3, total, temp, ten, temp2, totalk, tolerance;
int color4;
cout << "9999999999999999999999999999999999999999999999999999";
ten = 10;

cout << "First 3 Color Key:" << endl << "Black-0 Brown-1 Red-2 Orange-3 Yellow-4 Green-5" << endl << "Blue-6 Violet-7 Gray-8 White-9 Gold-10 Silver-11" << endl << endl;
cout << "Enter first color: ";
cin >> color1;
cout << "Enter second color: ";
cin >> color2;
cout << "Enter third color: ";
cin >> color3;

cout << "Fourth Color Key: Gold-0 Silver-1 None-2" << endl << endl;
cout << "Enter fourth color: ";
cin >> color4;

cout<< endl;

switch (color4)

{

case 0:

tolerance =5;

break;

case 1:

tolerance = 10;

break;

case 2:

tolerance = 20;

break;

default:

cout << "Invalid Input for fourth color tolerance value may be wrong." << endl << endl;
}

temp = color1*10+color2;
temp2 = pow(ten,color3);

total= temp*temp2;
totalk = total/1000;

cout << "Your resistor's value is " << total << " or " << totalk<< "k ohm's with a tolerance of +/- " << tolerance << "%." << endl << endl;

return 0;

}```

2. I can help over AIM

3. You are outputting all those 9's as a string. Yes, that will show, always. Aside from that I had no problems O.o

4. I think it is the case of the variable... because.. it is long double ... but there can be a method to display it in the other way... as u intended to display

5. the variable total is the one I was having problems with. Ignore the 9's . What type of variable should it be? Thanks

6. the long double is storing the wanted number, and your number is the range of what a long double can take, but it's just outputing it in a different way. It's the same.
Is that your question.

7. Does anyone know how to output it the normal way? Thanks again for replies!!

8. You may be looking to add cout << setprecision(x); where x = number of decimal places desired. Requires #include <iomanip.h>.

Your code is non-standard but compiles and executes fine on Borland 5. Just displays a ton of zeroes without setprecision().

-Skipper

Popular pages Recent additions