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. Thnx.. it was clearly explained... tomorrow i have
View Tutorial          By: Susmitha Sen at 2012-03-25 09:34:29

2. hi and thanks for this good example , i want ask i
View Tutorial          By: Maryam at 2011-12-17 11:19:07

3. "This happens immediately, and before any oth
View Tutorial          By: David at 2007-10-02 06:52:20

4. I want to enter data from a textbox to recordstor
View Tutorial          By: Rahul Maurya at 2010-04-10 01:04:51

5. nice 1
View Tutorial          By: vivek at 2013-03-19 16:25:47

6. Caught java.lang.ClassNotFoundException: com.sun.c
View Tutorial          By: A.Balaji at 2010-09-13 00:15:48

7. Hi every one. I am working on my project in j2me a
View Tutorial          By: wazir at 2010-11-26 08:27:43

8. realy very nice artical it give good understable
View Tutorial          By: vivek at 2009-06-19 01:27:46

9. good. keep it up !
View Tutorial          By: hashu at 2011-06-21 01:49:59

10. Hi, i am newly in java,please send me on sample pr
View Tutorial          By: aruna.k at 2012-12-13 06:05:44