This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/34192] [4.2, 4.3 Regression] NEAREST can return wrong numbers



------- Comment #7 from kargl at gcc dot gnu dot org  2007-11-22 19:00 -------
(In reply to comment #6)
> Created an attachment (id=14609)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14609&action=view) [edit]
> Patch (reverted Rev 117584) plus test case
> 
> Initial implementation by reverting Rev. 117584 as suggested by Steve.
> 
> Problems:
> - nearest(x,-1) for negative denormal x does not give a smaller number
> - returned values are not the smallest possible:
>   4.9406564584124654E-324 vs. 1.11253692925360069E-308
>   1.4012985E-45 vs. 5.87747175E-39

To fix this problem, I believe that you need to set emin to emin - prec + 1

Something like

+  mpfr_set_emin ((mp_exp_t) (gfc_real_kinds[sgn].min_exponent - 
                              gfc_real_kinds[sgn].digit + 1));

It might be a -1.

IIRC, mpfr always stores a normalized significand, so you need to
play with emin to properly account for gradual underflow.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34192


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]