Wednesday, March 20, 2019

float vs double

float

If we want 5 to 6 decimal places of accuracy then we should go for float.

Float data type is a single-precision 32-bit IEEE 754 floating point.

Float is mainly used to save memory in large arrays of floating point numbers.

Default value is 0.0f.

Takes 4 bytes to store a variable.

Range is -3.4 E38 to +3.4 E3

double

If we want 15 to 16 decimal places of accuracy then we should go for double.

double data type is a double-precision 64-bit IEEE 754 floating point.

This data type is generally used as the default data type for decimal values, generally the default choice.

Default value is 0.0d.

Takes 8 bytes to store a variableRange is -1.7 E308 to +1.7 E308

No comments:

Post a Comment