Yogesh Chauhan's Blog

# What is the difference between float and double?

in Miscellaneous on February 23, 2020

### Double

It has the double precision (15 decimal digits of precision). It usually occupies 64 bits in computer memory and represents fractional values. double occupies twice the memory occupied by float.

Double precision may be chosen when the range or precision of single precision would be insufficient.

One of the first programming languages to provide single- and double-precision floating-point data types was Fortran.

Double takes 8 bytes for storage.

### Float

It has single precision (7 decimal digits of precision). It usually occupies 32 bits in computer memory and represents a wide dynamic range of numeric values.

Float takes 4 bytes for storage.

NOTE: Here's how the number of digits are calculated:

double has 52 mantissa bits + 1 hidden bit = 53 bits: (53*log(2))/log(10) = 15.95 digits

float has 23 mantissa bits + 1 hidden bit = 24 bits: (24*log(2))/log(10) = 7.22 digits