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



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 works , i had a lot of trouble but finally , i
View Tutorial          By: Omer at 2009-06-30 06:05:17

2. sorry i think that's a constructor...just had one
View Tutorial          By: Gautam at 2013-10-14 15:55:14

3. what if i want to create a digital signature on th
View Tutorial          By: Chandra at 2012-06-10 00:52:15

4. Good intro..
View Tutorial          By: thirunavukkarasu at 2015-01-30 17:32:10

5. what about asp.net?
View Tutorial          By: tradeready at 2009-05-06 03:04:20

6. int n = 0;
for (int m = 0; m < 5; m++) {

View Tutorial          By: max at 2011-05-26 09:41:26

7. its good,,,can it be done more simpler without usi
View Tutorial          By: gahanaatherya at 2013-10-14 11:50:02

8. thank you.
View Tutorial          By: lluulnw at 2014-11-22 12:39:35

9. i want divide the jsf page to two pages
pl

View Tutorial          By: habib_fci at 2008-06-11 06:05:29

10. This is really helpful, i'm planning to also add a
View Tutorial          By: JhunZhen at 2011-07-09 21:42:32