The number in more than 3 decimal places ?

  • Thread starter mbolhi
  • Start date
In summary, the conversation discusses how to display numbers with more than 3 decimal places in a program using C language. The solution is to use long float or double type variables and make sure the print instruction converts the variable to the correct format. References and resources for learning more about C programming are also mentioned.
  • #1
mbolhi
10
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!
 
Technology news on Phys.org
  • #2
Hi,
in C language you can use longfloat command..
E.g., try %12.10lf command and see the result..
 
  • #3
thnaks but am a bit confused as to how to use this command ?

lf in front of the number?

show me teh xyntax please.

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

any reference or link would be much appreciated

thanks for ur help ;)
 
  • #6
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
 
  • #7
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.
 

1. What is the significance of numbers with more than 3 decimal places?

Numbers with more than 3 decimal places are important in scientific calculations and measurements because they provide a higher level of accuracy. They allow for more precise and detailed calculations, which is crucial in many fields of science.

2. Can numbers with more than 3 decimal places be rounded?

Yes, numbers with more than 3 decimal places can be rounded to a desired level of precision. However, it is important to note that rounding can introduce a margin of error, so it should be done carefully and with consideration to the level of accuracy needed for the specific calculation or measurement.

3. How do scientists handle numbers with more than 3 decimal places in their experiments?

Scientists typically use tools such as calculators or computer software to handle numbers with more than 3 decimal places in their experiments. These tools are able to perform calculations and store data with a high level of precision, allowing for accurate results.

4. What is the difference between numbers with 3 decimal places and numbers with more than 3 decimal places?

The main difference is the level of precision and accuracy. Numbers with more than 3 decimal places provide a higher level of detail and accuracy, while numbers with only 3 decimal places may be rounded and therefore have a lower level of precision.

5. Are numbers with more than 3 decimal places always necessary in scientific calculations?

It depends on the specific calculation and the level of accuracy needed. In some cases, numbers with more than 3 decimal places may not make a significant difference and can be rounded without affecting the overall result. However, in other cases, such as in advanced physics or chemistry experiments, numbers with more than 3 decimal places may be crucial for obtaining accurate and precise results.

Similar threads

Replies
25
Views
3K
  • Programming and Computer Science
Replies
17
Views
1K
Replies
6
Views
644
  • Programming and Computer Science
Replies
1
Views
505
Replies
4
Views
926
  • General Discussion
2
Replies
53
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
9
Views
1K
Back
Top