The difference between float and double

Thank you.

We all know float and double as the primitive datatypes of any programming language. But plenty of us still get confused regarding the basic meaning of these datatypes.

In technical terms, float is known as the Single precision floating point datatype whereas double is considered to be double precision floating point datatype.


Now in simple terms, single precision floating point’s significand has a precision of about 24 bits which lasts up to 8 decimal digits and double precision floating point’s significand has a precision of 53 bits which lasts up to 16 decimal digits.

In summary, we can say that, float can allow maximum 8 decimal digits while double allows 16.

It is as simple as that.


Following  Java program will depict above scenario quite clearly.

package samplejavaprograms; 

public class DifferenceBetweenFloatAndDouble {

public static void main(String[] args) {

float f = 0.123456789f;

double d = 0.1234567890d;

              System.out.println(“Float : ” + f);

              System.out.println(“Double : ” + d);





If you take a close look at the output, you will see that after the 7th digit of float, 8th digit is rounded off which clears the fact the float allows only 8 decimal digits and as far as double is concerned, it allows the same thing up to 16 decimal digits.


Hope you had a great read. Suggestions and improvements are always welcome.

Published by milindjagre

I founded my blog four years ago and am currently working as a Data Scientist Analyst at the Ford Motor Company. I graduated from the University of Connecticut pursuing Master of Science in Business Analytics and Project Management. I am working hard and learning a lot of new things in the field of Data Science. I am a strong believer of constant and directional efforts keeping the teamwork at the highest priority. Please reach out to me at for further information. Cheers!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: