real_info.subnormal off-by-one?

Steve Kargl sgk@troutmask.apl.washington.edu
Mon May 9 17:02:00 GMT 2005


On Mon, May 09, 2005 at 05:51:23PM +0200, Tobias Schl?ter wrote:
> 
> you defined the subnormal field in the real infos as:
>       /* subnormal (x) = b**(emin - digit + 1) */
>       mpfr_set_ui (b, real_info->radix, GFC_RND_MODE);
>       mpfr_pow_si (b, b, real_info->min_exponent - real_info->digits + 1,
> 		   GFC_RND_MODE);
> 
>       mpfr_init (real_info->subnormal);
>       mpfr_set (real_info->subnormal, b, GFC_RND_MODE);

(snip)

> i.e. in both cases subnormal is by a factor 2 larger than the smallest
> representable number.  Note that tiny is b**(emin-1), I also think that the
> number model in the standard is normalized to 0.1.... whereas IEEE floats are
> normalized to 1....., which would explain the difference.
> 
> Do you agree that this is wrong or did I misunderstand the meaning of the
> subnormal field?

It could be off-by-one.  If we consider REAL(4), then digit is 24
within the mpfr representation and a IEEE 32-bit real also has digit
of 24, but one bit is the hidden bit (as you note).  I recall looking
at the output of gfortran, but I don't remember why I added the 1.
Possibly, I had misread gcc/real.c where the mpfr number is finally
sent.  Anyway, if you think the 1 is a mistake, I have no objections
to removing it. 

-- 
Steve



More information about the Fortran mailing list