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. it should be:
/* --------------- */

View Tutorial          By: Ryba at 2010-05-19 15:45:48

2. Appriciated, The information is very useful and st
View Tutorial          By: Bala Gummadi at 2009-02-24 10:01:50

3. I am very much thankfull to you in providing the c
View Tutorial          By: c vijaychandar at 2010-05-05 10:14:59

4. "Type safety: The method add(Object) belongs
View Tutorial          By: WalterB Ntuli at 2010-04-09 01:51:17

5. I like ASP.net b'cs it is very easy to understand
View Tutorial          By: prachi at 2010-06-02 06:04:50

6. thanks a lot that helped.. =D
View Tutorial          By: Karthik at 2008-11-16 02:27:53

7. Nice example but does not work on me, after execut
View Tutorial          By: Junjie Zhang at 2012-01-10 03:26:12

8. not good not bad...............
View Tutorial          By: mahesh at 2010-10-05 00:45:54

9. Dear admin,
your Recaptcha design is not go

View Tutorial          By: surendra kumar sharma at 2013-02-02 05:58:35

10. HI can you send send sms throgh java program above
View Tutorial          By: sasikumar at 2007-02-27 01:39:11