Re: G_MINFLOAT definition?



Erik Walthinsen <omega temple-baptist com> writes:

> While porting to GObject, we started to make use of the G_MIN and G_MAX
> macros as default min/max for object parameters.  For a float parameter,
> one would think that the min and max would be +- the largest absolute
> value that the type can store, just like for G_MININT and G_MAXINT.
> However, this doesn't appear to be the case.  G_MINFLOAT is defined as
> FLT_MIN on my machine, which is defined in GCC's float.h as:
> 
>    /* Minimum normalised float */
> #undef FLT_MIN
> #define FLT_MIN 1.17549435e-38F
> 
> I don't know what a normalized float is, but it looks a lot like epsilon
> to me (but it isn't).
> 
> I checked the glib-1.2 documentation, and it simply says that G_MINFLOAT
> is "The minimum value which can be held in a gfloat.".
> 
> My opinion here is that either the documentation should be changed to
> reflect that G_MINFLOAT is not quite what it sounds like, or G_MINFLOAT
> really should be -(G_MAXFLOAT).
> 
> Thoughts?

The docs should be fixed. I think breaking the correspondence
with FLT_MIN would be undesirable.

Normalization means, essentially, removing leading 0's from
the mantissa of a floating point number.

That is, in decimal, turning 0.05 to 5.00 x 10^-2.

Once you hit the minimum value of the exponent, then you
must represent numbers in denormalized form, and thus loose
precision.

-G_MAXFLOAT should work fine for the most negative floating
point number.

Regards,
                                        Owen






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]