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: unassig...@gcc.gnu.org
        ReportedBy: thenl...@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.

Reply via email to