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 6 of 12 Topic 15906 of 16566
Post > Topic >>

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

by "Jeff Higgins" <oohiggins@[EMAIL PROTECTED] > Mar 22, 2008 at 07:23 PM

Patricia Shanahan 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.

Well, anyone reading this thread is already convinced of my
mathematical naivety, so continuing without embarrassment ...

Can I say that there are 0x007fffff float values that can be
represented in the range?

Can I say that 1f/0x007fffff is the first float value that can
be represented in this range, and that 2f * 1f/0x007fffff will
be the second?

This all came about because I am using a JSlider control to pick
values for an java.awt.Color, where the arguments to the Color
constructor are values between 0f - 1f.  Because JSlider only
operates with integer values I was using a range of 0 - 10000
and then multiplying by .0001 to get my float value.  I was trying
to find a better range of integers to use for my JSlider range
so that when I display the value I've picked with the slider
I don't get ugly .50168 or some such for .5.  I guess I'll probably
be better off dealing with that on the display end using printf or
decimalFormat or such.

Thanks for the info.
JH


> Patricia
 




 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 16:02:20 CST 2008.