public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/48878] New: Default I/O rounding on output should be round to nearest
@ 2011-05-05  4:26 jb at gcc dot gnu.org
  2011-05-05 13:00 ` [Bug libfortran/48878] " jvdelisle at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jb at gcc dot gnu.org @ 2011-05-05  4:26 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Default I/O rounding on output should be round to
                    nearest
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jb@gcc.gnu.org


When the IO rounding mode is not specified or is specified as
PROCESSOR_DEFINED, we should use NEAREST (corresponding to roundTiesToEven in
IEEE 754-2008). Currently we use COMPATIBLE (corresponding to roundTiestToAway
in IEEE 754-2008).

- Nearest is the default rounding mode for FP arithmetic.

- This is what most libc implementations use.

- As we don't support rounding on input, due to the above most likely nearest
will be used on input.

- Nearest rounding is usually preferable to compatible due to avoiding
positive/negative bias for positive/negative values. 

Alternatively, we could take care to always specify the correct number digits
to use when calling snprintf() when using PROCESSOR_DEFINED or unspecified
rounding, and then skip our own rounding step thus saving a bit of cpu time.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libfortran/48878] Default I/O rounding on output should be round to nearest
  2011-05-05  4:26 [Bug libfortran/48878] New: Default I/O rounding on output should be round to nearest jb at gcc dot gnu.org
@ 2011-05-05 13:00 ` jvdelisle at gcc dot gnu.org
  2012-03-15 15:16 ` jb at gcc dot gnu.org
  2012-03-15 15:21 ` jb at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-05-05 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot
                   |                            |gnu.org

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-05-05 12:51:49 UTC ---
"A processor is free to select any I/O rounding mode for the default mode. The
mode might correspond to UP, DOWN, ZERO, NEAREST, or COMPATIBLE; or it might be
a completely different I/O rounding mode.'

I think the standard has a funny way of telling people not to rely on default
rounding modes, i.e. be explicit if it matters. This will do it.  I am OK with
nearest

Index: write_float.def
===================================================================
--- write_float.def    (revision 173411)
+++ write_float.def    (working copy)
@@ -236,6 +236,8 @@
     if (!sign_bit)
       goto skip;
     goto updown;
+      case ROUND_PROCDEFINED:
+      case ROUND_UNSPECIFIED:
       case ROUND_NEAREST:
     /* Round compatible unless there is a tie. A tie is a 5 with
        all trailing zero's.  */
@@ -263,8 +265,6 @@
           }
       }
      /* Fall through.  */ 
-      case ROUND_PROCDEFINED:
-      case ROUND_UNSPECIFIED:
       case ROUND_COMPATIBLE:
     rchar = '5';
     goto do_rnd;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libfortran/48878] Default I/O rounding on output should be round to nearest
  2011-05-05  4:26 [Bug libfortran/48878] New: Default I/O rounding on output should be round to nearest jb at gcc dot gnu.org
  2011-05-05 13:00 ` [Bug libfortran/48878] " jvdelisle at gcc dot gnu.org
@ 2012-03-15 15:16 ` jb at gcc dot gnu.org
  2012-03-15 15:21 ` jb at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jb at gcc dot gnu.org @ 2012-03-15 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-03-15 15:14:49 UTC ---
Author: jb
Date: Thu Mar 15 15:14:43 2012
New Revision: 185433

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185433
Log:
2012-03-15  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/52434
        PR libfortran/48878
        PR libfortran/38199
        * io/unit.c (get_internal_unit): Default to ROUND_UNSPECIFIED.
        (init_units): Likewise.
        * io/write_float.def (determine_precision): New function.
        (output_float): Take into account buffer with %f format, no need
        for our own rounding if unspecified or processor specified
        rounding.
        (DTOA): Simplify format string, add parameters.
        (FDTOA): New macros similar to DTOA, but using %f format.
        (OUTPUT_FLOAT_FMT_G): Stack allocate newf, determine correct
        precision and fill buffer.
        (EN_PREC): New macro.
        (determine_en_precision): New function.
        (WRITE_FLOAT): For G format, move buffer filling into
        output_float_FMT_G, use FDTOA for F format.
        (write_float): Increase buffer due to F format.

testsuite ChangeLog:

2012-03-15  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/52434
        PR libfortran/48878
        PR libfortran/38199
        * gfortran.dg/edit_real_1.f90: Don't assume roundTiesToAway.
        * gfortran.dg/round_1.f03: Likewise.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/edit_real_1.f90
    trunk/gcc/testsuite/gfortran.dg/round_1.f03
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unit.c
    trunk/libgfortran/io/write_float.def


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libfortran/48878] Default I/O rounding on output should be round to nearest
  2011-05-05  4:26 [Bug libfortran/48878] New: Default I/O rounding on output should be round to nearest jb at gcc dot gnu.org
  2011-05-05 13:00 ` [Bug libfortran/48878] " jvdelisle at gcc dot gnu.org
  2012-03-15 15:16 ` jb at gcc dot gnu.org
@ 2012-03-15 15:21 ` jb at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jb at gcc dot gnu.org @ 2012-03-15 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-03-15 15:19:27 UTC ---
As of r185433 we let snprintf() do the rounding, unless a non-default rounding
mode is explicitly requested. At least on glibc, snprintf does roundTiesToEven.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-15 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05  4:26 [Bug libfortran/48878] New: Default I/O rounding on output should be round to nearest jb at gcc dot gnu.org
2011-05-05 13:00 ` [Bug libfortran/48878] " jvdelisle at gcc dot gnu.org
2012-03-15 15:16 ` jb at gcc dot gnu.org
2012-03-15 15:21 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).