+3 votes
Apart from memory size of both data types,I want to know any other differences and also want to know when we use float and when we use double???
asked Oct 19, 2015 in Computer Science - IT by gypsiii
retagged May 12, 2016 by slow_learner | 52 views

1 Answer

+2 votes

Float - 7 digits (32 bit)
Double-15-16 digits (64 bit)

A variable of type float only has 7 digits of precision where as a variable of type double has 15 digits of precision. 

An Example :

If you need better accuracy, use double instead of float.

In general a double has 15 to 16 decimal digits of precision, while float only has 7.

This precision loss could lead to truncation errors in float than double.

If you have further doubts you could write a program in java and check the precisions  :

 float  a=10.6664287277627762;
double b=10.6664287277627762;

answered Oct 21, 2015 by slow_learner