Comment on Tutorial - float vs double data types in Java By Baski



Comment Added by : William Fraser

Comment Added at : 2015-06-07 16:37:52

Comment on Tutorial : float vs double data types in Java By Baski
Actually, the given accuracy just barely exceeds what is possible in a float. A float is stored as: 1 sign bit, 23 mantissa bits, 1 sign bit for the exponent, and 7 bits for the exponent value.

Since the largest value that can be stored in 23 bits is 8388608, two consecutive floats in this region are:

8380398/131072 = 63.93736267
8380399/131072 = 63.9373703

Meaning that it can just barely distinguish between 63.93736 and 63.93737, which is still MUCH better than the human eye!


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. java is new for me..... since i dont know from bas
View Tutorial          By: m.padma at 2011-08-08 15:40:23

2. It doesnt works in Mozilla Firefox.


View Tutorial          By: K Vijay Anand at 2010-06-20 09:11:26

3. I think u've done well, just that more examples wi
View Tutorial          By: Mac at 2011-01-23 10:22:10

4. Thank you, I need exactly this; cheers :)
View Tutorial          By: Lang at 2011-04-08 09:33:24

5. super
View Tutorial          By: asasdfsa at 2014-05-29 05:23:04

6. Exception in thread "main" java.lang.NoC
View Tutorial          By: RobustTm at 2008-12-18 23:19:46

7. hi Ashray P Shetty,
I'm getting the followi

View Tutorial          By: Balaji at 2010-11-25 14:16:23

8. Please provide web.xml for the example
View Tutorial          By: Amit at 2008-12-24 02:16:59

9. Good article..
View Tutorial          By: Sudarshan at 2011-03-28 02:57:53

10. plz send me some interview based simple java progr
View Tutorial          By: Abilesh at 2013-06-23 06:43:03