Difference between float and double..? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Difference between float and double..?

6th Jan 2018, 2:05 PM
Jayshri Patil
Jayshri Patil - avatar
14 Answers
+ 10
A float is a 32 bit IEEE 754 floating point. A double is a 64 bit IEEE 754 floating point. so it is just a matter of precision because neither of the fraction portions .8 and .65 have a terminating binary representation, so there is some rounding error. the double has more precision so it has slightly less rounding error. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html https://www.sololearn.com/discuss/95982/?ref=app https://www.sololearn.com/discuss/736163/?ref=app
6th Jan 2018, 2:13 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
@Jayshri I had deleted that message as soon as I typed realising that u said "ok" and not thank u.But due to some internet connection problem the message persisted there.Sorry for that :)
7th Jan 2018, 9:15 AM
Infinity
Infinity - avatar
+ 5
you can store 2.4 in either of them ,It makes no difference except in terms of memory usage of double being greater than float
7th Jan 2018, 6:18 AM
Infinity
Infinity - avatar
+ 4
@Jayshri See, float can store upto 7 decimal digits while double upto 15. There is no hard and fast rule to follow if u need to store 2.4 in either of them.But, it is better to store it in float just because it is saving memory for u. and as in for java u say we don't use double, i don't agree with that since we CAN use it ! To be more clear u can ask the actual java challenge question
7th Jan 2018, 7:12 AM
Infinity
Infinity - avatar
+ 2
what is double used for??
7th Jan 2018, 2:49 PM
DEEPENDU PANDIT
DEEPENDU PANDIT - avatar
+ 1
if i have 2.4 value then it is store in which data type...
7th Jan 2018, 2:38 AM
Jayshri Patil
Jayshri Patil - avatar
+ 1
u r r8 but agar 2.4 float mai store hora 1st preference kisko dena chahiye
7th Jan 2018, 6:28 AM
Jayshri Patil
Jayshri Patil - avatar
+ 1
interview mai ques karte hai to us time bola jata hai ye data kaha store hoga tab ans float hota hai...but yaha java mai decimal point kam ho ya jyada hamesh float use kiya jata hai...mai challege ke time mai float pe tick kiya to muze wrong bata ya tabse confuse hu mai...i have completed my BCA so i am store this value in float if more than 2 decimal then store in double..datatype...yesi concept hamai bola gya hai...
7th Jan 2018, 6:32 AM
Jayshri Patil
Jayshri Patil - avatar
+ 1
@infinity tqsm..
7th Jan 2018, 9:12 AM
Jayshri Patil
Jayshri Patil - avatar
+ 1
is kk....😊
7th Jan 2018, 9:19 AM
Jayshri Patil
Jayshri Patil - avatar
0
float is represented in 32 bits, with 1 sign bit, 8 bits of exponent, and 23 bits of the significand (or what follows from a scientific-notation number: 2.33728*1012; 33728 is the significand). double is represented in 64 bits, with 1 sign bit, 11 bits of exponent, and 52 bits of significand.
6th Jan 2018, 9:46 PM
Rashed Latif
Rashed Latif - avatar
0
when your program may use some value which is greater than the maximum range of float then it's Better to use double.
7th Jan 2018, 6:05 PM
Rashed Latif
Rashed Latif - avatar
0
normaly we can say that double is use for storing the decimal no....in normal number we store in int ,long this type decimal number also store in float and double..float store for minimum decimal no..and double is also store decimal number but lagger number in decimal that number also store in double not in float according to os their storing capasity is different....
9th Jan 2018, 2:29 AM
Jayshri Patil
Jayshri Patil - avatar