mihajlv
mihajlv

Reputation: 2315

Why is this long double not printing out correctly using printf?

I need to do division using long double, on the order of 1/10^23, however the numbers get cut off when i check them using printf. Does anyone one know how I can see the full number? For example:

long double a = 1;
long double b = 3;
printf ("%Lf", a/b );

But I get:

0.333333

For example I would like to display the full number like here

Upvotes: 1

Views: 3782

Answers (1)

janneb
janneb

Reputation: 37208

%f format prints with 6 digits after the decimal point. You can use %.df to print d digits. Or better yet, use %.dg to make large/small values readable as well.

Upvotes: 3

Related Questions