This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Re: [Patch, libfortran] PR 52434/48878/38199 Improve floating point formatted writes


On Thu, Mar 15, 2012 at 01:52, Jerry DeLisle <jvdelisle@charter.net> wrote:
> I like the idea behind this patch. ÂI confess, I have not studied the two
> test cases that you are modifying, but the changes seem to stick out with
> too many digits there. ÂIs this really correct?
> When I get another moment, I will look closer. Maybe you can explain the
> need for this change a little more. ÂSorry if I am being to careful. Its
> been many months since I delved into the formatting code.

The reason is that with the patch, the default rounding is whatever
snprintf() gives us. At least with glibc, snprintf() rounds ties to
even, but I'm not sure all implementations do this rather than
rounding ties to away. So the testcase changes just make sure that
we're not rounding a tie. E.g. "1.25" rounded to two significant
digits is "1.2" if one rounds ties to even, "1.3" if ties are rounded
away. So using "1.250001" ensures that the rounded value is "1.3" with
both rounding modes.

I suppose another option would be to assume that rounding is ties to
even, and keep an eye out for regressions on other targets.


-- 
Janne Blomqvist


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