What is the difference between float data type and double Data type.. explain with an example?I am really confused about this in recent competitive programming question?

- 173
- 2
- 15

- 11
- 5
-
1Possible duplicate of [Difference between decimal, float and double in .NET?](https://stackoverflow.com/questions/618535/difference-between-decimal-float-and-double-in-net) – ZAhmed Aug 14 '17 at 06:41
2 Answers
The basic difference is that double contains information to a higher precision and a wider range.
in C++
float - single precision floating point type. Usually IEEE-754 32 bit floating point type. This is about 7 digits of precision with a range of ± 3.402,823,4 ·* 10^38
double - double precision floating point type. Usually IEEE-754 64 bit floating point type. This is about 15 digits of precision with a range of ± 1.797,693,134,862,315,7 * 10^308
see http://en.cppreference.com/w/cpp/language/types for a bit more detail

- 2,180
- 8
- 25
- 28
-
I think you mean a float occupies *half* as much space as a double. i.e. 4 bytes for a float instead of 8 bytes for a double. – Dragonthoughts Aug 22 '17 at 09:16
-
A float is a single precision, 32-bit floating-point data type that accommodates seven digits. Its range is approximately 1.5 × 10−45 to 3.4 × 10*38. A double is a double-precision, 64-bit floating-point data type. It accommodates 15 to 16 digits, with a range of approximately 5.0 × 10−345 to 1.7 × 10*308.