Alex Kizub wrote:
> On Mar 22, 4:34 pm, Lew <l...@[EMAIL PROTECTED]
> wrote:
>> Patricia Shanahan wrote:
>>> Perhaps you could identify a bit pattern in that range that does not
>>> represent a floating point number, or a bit pattern outside the range
I
>>> gave that corresponds to a floating point number in 0f through 1f.
>> Alex.From.Ohio.J...@[EMAIL PROTECTED]
wrote:
>>>> 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.
>> So there are 31 bits, plus the sign bit.
>>
>> Alex.From.Ohio.J...@[EMAIL PROTECTED]
wrote:
>>>> 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
>> 2 ** 23 * (2 ** 7 - 1 )
>> = 2 ** 30 - 2 ** 23
>>
>> Your calculations already are on the order of 2 ** 30.
>>
>> Patricia Shanahan wrote:
>>> Normalized floats in IEEE754 do not store the leading 1 bit. However,
>>> the positive denomalized floats, bit patterns 0x00000001 through
>>> 0x007fffff, are also in the specified range.
>> --
>> Lew
>
> OK, OK.
> Little tiny hint doesn't work.
> Let's use brutal force:
>
> float f;
> long i=0, c=0;
> for(; (i&0x100000000L)==0; i++){
> f=Float.intBitsToFloat((int)i);
> if (f<=2f&&f>=0f){
I don't understand this test. Why "f<=2f" rather than "f<=1f"? 1.5f is
exactly representable and is less than 2f, but is not in the required
range.
> c++;
> }
> }
> System.out.println(c+" "+i);
> System.out.println(Math.pow(2, 30));
>
>
> and output is:
>
> 1073741826 4294967296
> 1.073741824E9
>
> As you can see float range from 0 to 1 inclusively is 2**30 + 2
> (which are -0 and 1).
>
> Sincerely, Alex.
> http://www.myjavaserver.com/~alexfromohio/


|