Alex.From.Ohio.Java@[EMAIL PROTECTED]
wrote:
> 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.
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.
> 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.
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.
> 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.
To the limited extent that they are distinct values, I would not think
of -0 as being in the range. -0 seems to me more like a placeholder for
negative values that underflow to zero. On the other hand, if they are
the same value then including -0 makes no difference in the count of
float values.
Patricia


|