Variable type for deciamls

I have to display a number like 2.3284646746 keeping all the digits. Is there a variable type that can hold this number without cutting off most of it?

The code:

long double num3;


num3 = 124.12345678910;

cout <<"The long double of the number is " << num3 << "." << endl;

It displays 124.123.

Last edited on
long long double.

Aceix.
Thank you, but it still displays 124.123. Any idea why?
Thank you for your help.
Your trouble is likely not with the precision of your variable, but rather with the precision of the output. Try the following...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
long double num3;


num3 = 124.12345678910;

cout <<"The long double of the number is " << fixed << setprecision(12) << num3 << "." << endl;	
return 0;

}
Thank you. It worked.
Topic archived. No new replies allowed.