The number in more than 3 decimal places ?

  • Thread starter Thread starter mbolhi
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
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 ;)
 
Hi,
well, please look into any C-programming book..just first few pages or 1st chapter..you will find 'lf' explained..
you can also see 'let us c' by y. ganetkar.
or http://www.cs.cf.ac.uk/Dave/C/CE.html
cheers
 
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.