This explanation was written keeping in mind the confusion caused by the fact that one has two different types of floating point numbers at their disposal. Read below to find out what you could be missing out on in your C programs.
Firstly, you must know that a "Floating point number" refers to a number with a decimal place followed by a number or numbers. Also there are what some may refer to as "Two types of floating point number types." Although they are more or less the same with different features, as they do the same thing in slightly different ways.
What differences will I notice when I opt for “double” as opposed to “float” or vice versa:
- By using the "float" function to create a floating point number you are creating a variable that is capable of storing a numerical data value (number) within itself with up to 7 numbers after the decimal point. Wow! Accuracy to seven points, that sounds crazy. This is the most commonly used floating point variable type.
- By using the "double" function to create a floating point number, you are creating a variable that is capable of storing a numerical data value inside itself with not seven, but 15 numbers after the decimal point. Which means you can have up to 15 point of accuracy on a single integer. This type of floating point number variable is used more rarely, in applications that require utmost accuracy.
Perhaps you would like to know about signed and unsigned integers in C while you are here? If so you must see the explanation linked below:
Hopefully this explanation has removed your once-hazy understanding of the different types of "Floating point numbers" in C. Enjoy your newfound C language knowledge.