Thursday, October 28, 2010

What does double precision variable mean in C?

If you know what float is, then double is like an advanced version of float. It can hold a larger number value because the variable can hold more bytes of memory.
Now if you don't know what a float is then read this:
if you notice. If you name a variable with the type "int" you can only put in whole numbers and not decimal numbers (Ex: 1 , -1 , 100 , -100 , etc)

With double you can store any type of number in the variable Ex: 1.0 , 2.56783 , 2.192
Now float is a lower version of double and can still store any number but it can't store very large numbers. Most times people use double instead of float , but there's some good situations when you'd use float over double for example. Say the variable won't be a large value then you'd use float because it takes up less space and therefore the program will run faster.

So to sum it all up
1.Double means that the number stored in the variable is a real number , meaning you can store numbers with decimals and what not.
2. Double can hold a larger number value than int or float because it can hold more bytes of memory.
3. Double is most commonly used , rather than float.

No comments: