Re: [GD-General] FLT_MIN
Brought to you by:
vexxed72
|
From: Colin F. <cp...@ea...> - 2003-01-03 08:02:18
|
2003 January 2nd
Thursday
Pierre,
IEEE 32-bit floats are in the following format:
SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM
33222222222211111111110000000000
10987654321098765432109876543210
The 8 exponent bits EEEEEEEE form
a number from 0 to 255.
The interpretation of this exponent
is as follows:
0 : Denormalized number; No implicit
leading "1" bit in mantissa; First bit
in explicit mantissa bits (MMMMM...) is
now the actual leading bit with an effective
value of 1.0; Exponentiated value is
(2^(-127)).
1..254 : Exponent is (EEEEEEEE - 127)
255 : Mantissa contains special number
codes (NaN, undefined, infinity)
Here's a quote from my <float.h> file:
#define FLT_MIN 1.175494351e-38F /* min positive value */
This value is roughly equal to 2^(-126), which
really *IS* the minimum positive FLOATING POINT
value. In bit form:
0:0000001:00000000000000000000000
S = 0; E = 1; M = 1.0
Hence: 1.0 * 2^(1 - 127) = 2^(-126)
Your expression:
(0.5f*sqrtf(FLT_MIN)) *
(0.5f*sqrtf(FLT_MIN))
is not zero, because the product has some
room in the "denormalized" range.
If the exponent number is "0",
then we're in "denormalized" territory.
The exponent part is thus (2^(-127)),
and the denormalized value can be a single
"1" bit in the least-significant bit
of the mantissa, with an effective
denormalized (no implicit "1" bit)
mantissa value of (2^(-22)). Thus,
a denormalized number can be as
small as: ((2^(-127)) * (2^(-22)) =
(2^(-149)) = 1.401298464E-45 roughly.
Thus, if you allow for denormalized
numbers, 1.401298464E-45 is the
minimum positive value, as you have
observed. (Or, 0x00000001 in memory viewed
as hex, as you pointed out.)
--- Colin
cp...@ea...
http://www.colinfahey.com
----- Original Message -----
From: "Pierre Terdiman" <p.t...@wa...>
To: <gam...@li...>
Sent: Thursday, January 02, 2003 2:55 PM
Subject: [GD-General] FLT_MIN
> Here's something I don't get....
>
> I was looking for the smallest floating-point value F such as F^2 doesn't
> underflow. So, I wrote something like :
>
> F^2 = FLT_MIN ;
> => F = sqrtf ( FLT_MIN ) ;
>
> Then, as a test, I wrote :
>
> const float HalfSqrtFMin = sqrtf(FLT_MIN) * 0.5f;
> const float f = HalfSqrtFMin*HalfSqrtFMin;
>
> I was expecting f to be zero due to underflow. Yet it wasn't. That was my
> first clue something weird was going on.
>
> So I investigated a bit more and found that the floating-point value I was
> looking for was 1.40130e-045, which gives zero once squared. This is the
> floating-point value whose binary representation is 0x00000001.
>
> I've always thought FLT_MIN was the "min positive value" (as stated in
> Float.h). What the hell is that number then ? I'm sure I'm missing
something
> obvious....
>
> Pierre
>
> PS: http://www.codercorner.com/FPU.jpg
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Gamedevlists-general mailing list
> Gam...@li...
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=557
|