public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/48925] New: Code cleanup in write_float.def
@ 2011-05-07  8:48 thenlich at users dot sourceforge.net
  2011-05-25  2:05 ` [Bug libfortran/48925] " jvdelisle at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-05-07  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Code cleanup in write_float.def
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: thenlich@users.sourceforge.net


For improvement in code quality and possible future modifications, I suggest to
separate the steps "digit generation" and "number formatting" into separate
functions.

1. There should be a function "Digit generation".
Input:
- a floting-point number (e.g. -.123456789E+12)
- the rounding mode (up/down etc.)
- mode: fixed-point (F editing), or floating-point (E/ES/G), or engineering
(EN) 
- number of significant digits (floating-point), number of decimal digits (F)

Output:
- a string with the digits of the rounded significand (e.g. "123457")
- an integer exponent (e.g. 12), or position of the decimal separator
- the sign flag (- or +)

2. There should be a function "number formatting"
Input:
- s.a. Output
- the edit descriptor (F/E/G...)
- Field width w and number of requested digits d

Output:
- A buffer with the formatted number (e.g. "   +1.23457E+011")

Function 2 is independent of the floating-point precision, so we don't need it
four times for all the different real kinds, only one time.


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

end of thread, other threads:[~2014-01-16  2:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-07  8:48 [Bug libfortran/48925] New: Code cleanup in write_float.def thenlich at users dot sourceforge.net
2011-05-25  2:05 ` [Bug libfortran/48925] " jvdelisle at gcc dot gnu.org
2014-01-14 22:23 ` dominiq at lps dot ens.fr
2014-01-16  2:49 ` jvdelisle 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).