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

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

Java program to check if user input is an even number

Archived Comments

1. Re: Inner Classes
Aside from allowing acces

View Tutorial          By: lee smith at 2010-01-17 10:59:23

2. that is fifo rigth? how about lifo?
View Tutorial          By: galz at 2015-02-18 03:03:31

3. Hi there,
this doesnt work in IE7 or firefo

View Tutorial          By: Gerrard at 2009-10-17 15:19:24

4. please give me a program of the 12 horoscope using
View Tutorial          By: auvx at 2011-08-03 02:02:56

5. nice to learn abt it
View Tutorial          By: aice at 2012-08-25 12:49:35

6. But I have the same error ("javax.net.ssl.SSL
View Tutorial          By: azeemuddin at 2010-03-04 07:25:33

7. thnks lot 4 helping me
View Tutorial          By: sandeep dudi at 2011-11-17 06:06:03

8. Any thoughts on how conservative/liberal to be whe
View Tutorial          By: Jon at 2009-05-04 15:29:14

9. I 've tried the program for Bubble Sort. This prog
View Tutorial          By: Siva at 2012-04-17 05:19:28

10. My code runs smoothly. I have taken some steps for
View Tutorial          By: Amit Shrivastava at 2015-01-25 13:48:46