The number in more than 3 decimal places ?

  • Thread starter Thread starter mbolhi
  • Start date Start date
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
6 replies · 3K views
mbolhi
Messages
10
Reaction score
0
hello,

How could I make my answer display the number in more than 3 decimal places?

for example

Variable U = 0.026283623901941

instead of

U = 0.02628

which command to use?

thanks for ur help!
 
Physics news on Phys.org
Hi,
in C language you can use longfloat command..
E.g., try %12.10lf command and see the result..
 
thnaks but am a bit confused as to how to use this command ?

lf in front of the number?

show me the xyntax please.

thanks
 
printf ("\n something : %12.10lf",another);
do you know some basics of programming using C?
 
Last edited:
thansk, well I am quite novice

any reference or link would be much appreciated

thanks for ur help ;)
 
mbolhi said:
hello,

How could I make my answer display the number in more than 3 decimal places?

for example

Variable U = 0.026283623901941

instead of

U = 0.02628

which command to use?

thanks for ur help!

It looks like your using a single (BASIC) or a short float (C) type variable.

As others have mentioned use a double (BASIC) or a double (C) or long double when defining the variable. Also as others have mentioned make sure the print instruction converts the variable to the right format (double or long double) so that you don't get the truncation that is occurring.