public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thenlich at users dot sourceforge.net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/48906] Wrong rounding results with -m32
Date: Mon, 06 Jun 2011 12:27:00 -0000	[thread overview]
Message-ID: <bug-48906-4-ACNKo3Av3M@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-48906-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #26 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-06-06 12:27:38 UTC ---
(In reply to comment #25)
> My confusion seems to be when scale factor is to be ignored and when not,  I 
> will give the standard another read.

As it happens, you're not the only one to find (this part of) the Fortran
standard confusing and buggy, so if all goes as planned there will be a
rewrite:

---------------------------------------------------------------------
                                                    11-xxx
To: J3
From: John Reid and Thomas Henlich
Subject: Interp: G editing for reals
Date: 2011 June 5

---------------------------------------------------------------------

NUMBER: F08/xxxx
TITLE: G editing for reals
KEYWORDS: format, G editing
DEFECT TYPE: Erratum
STATUS: J3 consideration in progress

QUESTION:

1. Gw.d editing for a real value that is in the range (0.1,10**d) and 
is not near an integer power of 10 uses F editing to produce exactly 
the same value as 0PEw.d editing would produce. For values in this 
range that are near an integer power of 10, is it intended that F 
editing be used to produce exactly the same value as 0PEw.d editing 
would produce? 

The rules in 10.7.5.2.2 usually have this effect, but the following
examples illustrate exceptions for rounding UP and to ZERO.
  i. 
     print "(ru,g11.2)", -9.95 
  or
     print "(rz,g11.2)", -9.95 
  Here, 0PE11.2 editing would produce the value -0.99E+01, which can be 
  represented as -9.9. However, the standard requires F7.0 to be used, 
  which gives the result -9. Note that the standard requires
     print "(rd,g11.2)", 9.95
  and
     print "(rz,g11.2)", 9.95
  to give the result 9.9. 

  ii.
     print "(ru,0p,g11.2)", -99.5
  The standard requires 0PE11.2 editing to be used, which gives 
  -0.99E+02. This is representable as -99.

  iii. 
     print "(ru,0p,g11.2)", 99.
  The standard requires 0PE11.2 editing to be used, which gives 
  0.99E+02. This is representable as 99.


2. COMPATIBLE and NEAREST modes of rounding differ only when the two
nearest representable values are equidistant from the given value. The
similarity appears not to be represented in the second table. What is
meant by "if the higher value is even"?

3. Why is no account taken of the effects when PROCESSOR_DEFINED 
rounding is in effect? 


ANSWER:

1. Yes, this was the intention and it would be clearer for the standard
to state this directly. It would also be easier for implementers to 
implement. 

2. If the standard is rewritten as proposed in the first question, these
further problems would be resolved. 

3. If the standard is rewritten as proposed in the first question, 
PROCESSOR_DEFINED rounding would be covered. 

EDITS to 10-007r1:

[258:14-20] In 10.7.5.2.2, replace paragraph 4 by
"Otherwise, the method of representation in the output field depends
on the internal value being edited. Let N be the value that would be
output with 0PEw.dEe editing and let s be its exponent part unless N 
is identically 0 in which case let s be 1. Let k be the scale factor 
(10.8.5). Let b be a blank. For Gw.d editing, if s lies in the range
0 <= s <= d, F(w-4).(d-s),4('b') editing is used to represent N in the
output field; otherwise, kPEw.d editing is used to represent the
internal value. For Gw.dEe editing, if s lies in the range 0 <= s <= d, 
F(w-n).(d-s),n('b') editing where n=e+2 is used to represent N in the 
output field; otherwise, kPEw.dEe editing is used to represent the 
internal value." 


SUBMITTED BY: John Reid and Thomas Henlich 

HISTORY: 11-xxx    m195  Submitted

------------------------------------------------------------------------


  parent reply	other threads:[~2011-06-06 12:27 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-06  1:31 [Bug libfortran/48906] New: " jvdelisle at gcc dot gnu.org
2011-05-06 21:33 ` [Bug libfortran/48906] " jvdelisle at gcc dot gnu.org
2011-05-06 21:52 ` kargl at gcc dot gnu.org
2011-05-10 13:05 ` jvdelisle at gcc dot gnu.org
2011-05-10 17:21 ` thenlich at users dot sourceforge.net
2011-05-19  5:55 ` jvdelisle at gcc dot gnu.org
2011-05-19  8:36 ` thenlich at users dot sourceforge.net
2011-05-19 13:21 ` jvdelisle at gcc dot gnu.org
2011-05-23 19:27 ` jvdelisle at gcc dot gnu.org
2011-05-26 13:02 ` jvdelisle at gcc dot gnu.org
2011-05-27  7:21 ` thenlich at users dot sourceforge.net
2011-05-27  8:56 ` thenlich at users dot sourceforge.net
2011-05-27 13:14 ` thenlich at users dot sourceforge.net
2011-05-27 14:34 ` jvdelisle at gcc dot gnu.org
2011-05-30 18:53 ` jvdelisle at gcc dot gnu.org
2011-05-31  6:28 ` thenlich at users dot sourceforge.net
2011-05-31  6:41 ` thenlich at users dot sourceforge.net
2011-05-31 12:38 ` jvdelisle at gcc dot gnu.org
2011-06-01  5:09 ` jvdelisle at gcc dot gnu.org
2011-06-01  6:26 ` thenlich at users dot sourceforge.net
2011-06-01  8:13 ` thenlich at users dot sourceforge.net
2011-06-01 12:27 ` jvdelisle at gcc dot gnu.org
2011-06-02  3:58 ` jvdelisle at gcc dot gnu.org
2011-06-03 12:56 ` jvdelisle at gcc dot gnu.org
2011-06-06  8:38 ` thenlich at users dot sourceforge.net
2011-06-06 12:09   ` jerry DeLisle
2011-06-06 12:10 ` jvdelisle at charter dot net
2011-06-06 12:27 ` thenlich at users dot sourceforge.net [this message]
2011-06-06 12:36 ` jvdelisle at charter dot net
2011-06-06 12:42 ` thenlich at users dot sourceforge.net
2011-06-06 12:48 ` thenlich at users dot sourceforge.net
2011-06-07  6:56 ` thenlich at users dot sourceforge.net
2011-06-07  6:57 ` thenlich at users dot sourceforge.net
2011-06-07 17:06 ` jvdelisle at gcc dot gnu.org
2011-06-10 16:16 ` jvdelisle at gcc dot gnu.org
2011-06-10 16:22 ` jvdelisle at gcc dot gnu.org
2011-06-10 16:56 ` thenlich at users dot sourceforge.net
2011-06-10 17:02 ` thenlich at users dot sourceforge.net
2011-06-10 17:30 ` jvdelisle at gcc dot gnu.org
2011-07-01  9:23 ` thenlich at users dot sourceforge.net
2011-07-02  1:33 ` jvdelisle at gcc dot gnu.org
2013-06-16 16:56 ` dominiq at lps dot ens.fr
2014-01-11 21:44 ` jvdelisle at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-48906-4-ACNKo3Av3M@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).