Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: How many fl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 12 Topic 15906 of 16566
Post > Topic >>

Re: How many float values in range 0f - 1f inclusive?

by Alex.From.Ohio.Java@[EMAIL PROTECTED] Mar 22, 2008 at 11:27 AM

On Mar 22, 12:31 pm, Patricia Shanahan <p...@[EMAIL PROTECTED]
> wrote:
> Jeff Higgins wrote:
> > How many float values can be represented
> > in the range of 0f through 1f inclusive?
>
> Each bit pattern in the range Float.floatToIntBits(0f) through
> Float.floatToIntBits(1f) corresponds to a float value in the specified
> range.
>
> Patricia

It's not quite correct.
It's not Java question. It's about how float numbers are represented
in the memory.

This link provides good explanation:
http://en.wikipedia.org/wiki/IEEE_754

So, (don't forget normalization, which actually prevents such things,
but the DO exist in memory) we need to know what are
exponent (2*e) and fraction (1.+ .f) in our implementation.
In Java float is 32 bites.
So, e has 8 bits and f has 23.

Anything which is less then half of 2 is 1. So, All e<0 (127) are
between 0 and 1.
That's 2**23 * 127

And last number - don't forget +0 and -0 which are two different
representation of one number 0. So, we have +1 for -0 in total
calculation.

You do the math.

Alex.
http://www.myjavaserver.com/~alexfromohio/
 




 12 Posts in Topic:
How many float values in range 0f - 1f inclusive?
"Jeff Higgins"   2008-03-22 11:26:54 
Re: How many float values in range 0f - 1f inclusive?
Patricia Shanahan <pat  2008-03-22 09:31:16 
Re: How many float values in range 0f - 1f inclusive?
Alex.From.Ohio.Java@[EMAI  2008-03-22 11:27:56 
Re: How many float values in range 0f - 1f inclusive?
Patricia Shanahan <pat  2008-03-22 11:55:48 
Re: How many float values in range 0f - 1f inclusive?
Lew <lew@[EMAIL PROTEC  2008-03-22 16:34:19 
Re: How many float values in range 0f - 1f inclusive?
"Jeff Higgins"   2008-03-22 19:23:55 
Re: How many float values in range 0f - 1f inclusive?
"John B. Matthews&qu  2008-03-22 22:15:26 
Re: How many float values in range 0f - 1f inclusive?
"Jeff Higgins"   2008-03-24 08:13:54 
Re: How many float values in range 0f - 1f inclusive?
Alex Kizub <akizub@[EM  2008-03-23 06:09:11 
Re: How many float values in range 0f - 1f inclusive?
Patricia Shanahan <pat  2008-03-23 06:53:32 
Re: How many float values in range 0f - 1f inclusive?
Alex.From.Ohio.Java@[EMAI  2008-03-23 07:35:31 
Re: How many float values in range 0f - 1f inclusive?
Patricia Shanahan <pat  2008-03-23 08:04:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 15:40:34 CST 2008.