+ 1
What is the difference in using 'float' and 'double' data type in C language?
4 Answers
+ 3
float is a 32bit number, double is a 64bit number. Therefore double can store bigger numbers and they are more precise.
double is also the standard floating point type in modern compilers.
+ 3
My C++ professor recommended to never use Doubles because they take up alot more memory than Floats. The more complex your code the more you have to worry about memory requirements to keep code running fast.
+ 3
Memory usually isn't an issue nowadays, but it depends on the project (application size, intended hardware,...)
In most cases, you're safe when using doubles. Nobody ever recommended me using floats instead of doubles, except in machine learning, but there you're handling a massive amount of data at the same time.
If you want to use floats anyway, just remember to use float literals (e.g. 1.0f instead of 1.0) when using constants in calculations, because otherwise the compiler will use double
+ 3
Abu Sufian They are able to store larger numbers because the have more bits.