This is the mail archive of the gcc-patches@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]

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


On 03/15/2012 02:55 AM, Janne Blomqvist wrote:
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.



Understood, thanks. patch OK for trunk.



Jerry



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