# Long Numbers

• 11-14-2005
themexican
Long Numbers
i am trying to print in standard notation but it keeps printing in scientific notation. here is the coding.

Code:

```#include <iostream> using namespace std; int main() {         long double no1, no2, ans;     char ch1;         cout << "Enter an equation:";         cin >> no1 >> ch1 >> no2;     if (ch1 == '+')     {                 ans = no1 + no2;     }     if (ch1 == '-')     {         ans = no1 - no2;     }         cout<<ans<<endl;             return 0; }```
i am trying to get
123456789012345678901234567890 + 12345678901234567890
as the input to output
246913578024691357802469135780
• 11-15-2005
grumpy
Try using manipulators to change how floating point values are output. The catch is you need to use the manipulator every time you output a value (as the stream typically gets reset to defaults once the value is output)

Code:

`  cout << fixed << setw(20) << ans << endl;`
std::fixed is a manipulator that outputs floating point in fixed notation. std::setw() sets the width of the output for the next value.
• 11-15-2005
themexican
all this is doing is puttin a space of 50 chars in front of the scientific notation answer, it doesnt change it to standard notation. please help this is killing me.

Code:

```#include <iostream> #include <iomanip> using namespace std; int main() {         long double no1, no2, ans;     char ch1;         cout << "Enter an equation:";         cin >> no1 >> ch1 >> no2;     if (ch1 == '+')     {                 ans = no1 + no2;     }     if (ch1 == '-')     {         ans = no1 - no2;     }         cout <<  setw(50) << ans <<endl;             return 0; }```
• 11-15-2005
Frost Drake
As far as I know, you can use cout.precision(int n) to change the number of digits it displays, but careful about the maximum precision of the data type itself.
• 11-15-2005
themexican
k i got that but now if my answer doesnt fill the (int n) it puts zeros at the end of the answer