public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/115164] New: floating-point output generates misleading values with WriteFloat when sigfigs and width are zero
@ 2024-05-20 15:30 gaius at gcc dot gnu.org
  2024-05-20 15:36 ` [Bug modula2/115164] " gaius at gcc dot gnu.org
  2024-05-21  0:13 ` cvs-commit at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-20 15:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115164

            Bug ID: 115164
           Summary: floating-point output generates misleading values with
                    WriteFloat when sigfigs and width are zero
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

[Forwarded from the gm2 mailing list:
https://lists.nongnu.org/archive/html/gm2/2024-05/msg00009.html ]

For example if we use WriteFloat (pi, 0, 0) then the libraries issue a long
sequence of zeros once the precision runs out.  Consider the test code and
output below:

cat testwritereal.mod
MODULE testwritereal ;

FROM STextIO IMPORT WriteString, WriteLn ;
FROM SRealIO IMPORT WriteFloat ;
FROM RealMath IMPORT pi ;

BEGIN
   WriteString ('value of pi = ') ; WriteFloat (pi, 0, 0) ; WriteLn
END testwritereal.

$ gm2 testwritereal.mod
$ ./a.out 
value of pi =
31415926535897931159979634685441851615905761718750000000000000000000000000000000000000000000000000000

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

* [Bug modula2/115164] floating-point output generates misleading values with WriteFloat when sigfigs and width are zero
  2024-05-20 15:30 [Bug modula2/115164] New: floating-point output generates misleading values with WriteFloat when sigfigs and width are zero gaius at gcc dot gnu.org
@ 2024-05-20 15:36 ` gaius at gcc dot gnu.org
  2024-05-21  0:13 ` cvs-commit at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-20 15:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115164

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-05-20
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed.

Using the Matula and Goldberg formulas makes much more sense than the current
default output for width 0.  I'll add these formulas to LowReal, LowShortReal,
LowLongReal (there is already a constant 'places', which looks as if it is
incorrect).

gcc/m2/gm2-gcc/m2builtins.cc:597:doplaces: looks wrong.  A Matula value
for sigfigs should be adopted in SRealIO and friends (if the width and sigfigs
are 0).

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

* [Bug modula2/115164] floating-point output generates misleading values with WriteFloat when sigfigs and width are zero
  2024-05-20 15:30 [Bug modula2/115164] New: floating-point output generates misleading values with WriteFloat when sigfigs and width are zero gaius at gcc dot gnu.org
  2024-05-20 15:36 ` [Bug modula2/115164] " gaius at gcc dot gnu.org
@ 2024-05-21  0:13 ` cvs-commit at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-21  0:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115164

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:d642b66a298ece7394e786a6a2d14a4f0b561d9a

commit r15-700-gd642b66a298ece7394e786a6a2d14a4f0b561d9a
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Tue May 21 01:11:48 2024 +0100

    PR modula2/115164 initial test code highlighting the problem

    This patch includes some trivial testcode which highlights
    PR 115164.  Expect future test code to perform runtime checks
    for a series of trailing zeros.

    gcc/testsuite/ChangeLog:

            PR modula2/115164
            * gm2/isolib/run/pass/testlowread.mod: New test.
            * gm2/isolib/run/pass/testwritereal.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

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

end of thread, other threads:[~2024-05-21  0:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-20 15:30 [Bug modula2/115164] New: floating-point output generates misleading values with WriteFloat when sigfigs and width are zero gaius at gcc dot gnu.org
2024-05-20 15:36 ` [Bug modula2/115164] " gaius at gcc dot gnu.org
2024-05-21  0:13 ` cvs-commit 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).