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. here is one more inner class example
public

View Tutorial          By: shahalam shaikh at 2012-02-13 21:08:30

2. I want simple programs using BuffuredReader for m
View Tutorial          By: Why ask my name? at 2013-06-01 04:56:00

3. Please tell me the process, how to compile the mid
View Tutorial          By: Manish at 2008-11-14 13:33:43

4. Hi Sir...
sir i am a student and I am worki

View Tutorial          By: shanthi at 2013-03-22 11:01:15

5. Hi there! the coding are SUPERB..bt i do nd help i
View Tutorial          By: lily sandra at 2008-01-15 18:30:33

6. It was actually useful!!! Thanks for explaining in
View Tutorial          By: steph at 2010-01-28 21:59:06

7. This is a great article that deals with the evolut
View Tutorial          By: JPS SASTRY at 2009-02-11 21:29:56

8. i have an exception unknown host.
please te

View Tutorial          By: saddam hussain at 2011-03-22 10:46:48

9. Dear sir,
Can you provide me for a simple p

View Tutorial          By: kartikeya at 2012-12-22 10:19:41

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