Difference between Float , double and long double

Jeevitha M
featurepreneur
Published in
2 min readFeb 17, 2022

Float ,double and long double are primitive data types used by programming languages to store floating-point real (decimal) numbers like 10.158769, 389.547235 and so on.

In the computing world, numeric data is represented in fixed and floating numbers. There are three floating point types: float, double and long double . The type double provides at least as much precision as float, and the type long double provides at least as much precision as double . The set of values of the type float is a subset of the set of values of the type double ; the set of values of the type double is a subset of the set of values of the type long double

FLOAT

Ø It is generally used for graphic based libraries for making the processing power of your programs faster, as it is simpler to manage by compilers.

Ø It has single precision.

Ø According to IEEE, it has a 32-bit floating point precision.

Ø Float takes 4 bytes for storage.

Ø Has a precision of 6 decimal places.

DOUBLE

Ø This is the most commonly used data type in programming languages for assigning values having a real or decimal based number within, such as 3.14 for pi.

Ø It has the double precision or you can say two times more precision than float.

Ø According to IEEE, it has a 64-bit floating point precision.

Ø Double takes 8 bytes for storage.

Ø Has a precision of 15 decimal places.

LONG DOUBLE

Ø Long double takes 10 bytes for storage

Ø Has a precision of 18 decimal places

Ø According to IEEE, it has a 128-bit floating point precision.

Ø Long double is more precise than double float

In programming language that uses numeric data, the data types are to be considered on the basis of precision and storage. So if the program needs a precise answer it is better to switch with long double and double. And if the program requires a data type with less storage it is better to hold with float data type.

--

--

Jeevitha M
featurepreneur

AWS Cloud Captain Cohort 3 - India Region , Interested in Data Analytics , Big data, Cloud Computing [AWS/Azure]. A newbie in security . #Womenintech #Research