Yogesh Chauhan's Blog

What is the difference between float and double?

in Miscellaneous on February 23, 2020


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.


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

Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Killing A Project Part 4: What Would Be Your Top 3 Priorities For Planning The Cancellation?MiscellaneousIf statement shorthand examples in JavaScriptJavaScriptHow to set opacity or transparency using CSS?CSSHow to create Glowing Texts using CSS?CSSHow to solve “framework not found” error in Swift?SwiftIs there a difference between SCSS and Sass?SCSSClean Form Input With These PHP Functions Before Inserting into DatabasePHPHow to show slider value in HTML5 range input using JavaScript?HTMLHow to get previous days or next days in PHP?PHPWhat is Hoisting in JavaScript?JavaScriptHow to apply style to a specific child element using CSS?CSSHow to load a module with configuration in SCSS?SCSS