Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4023105

Float.toString(1.0e7f) produces "1.0E+7" instead of "1.0E7"

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0fcs
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description


      masayoshi.okutsu@Eng 1996-12-20
      Float.toString(1.0e7f) produces "1.0E+7" instead of "1.0E7", which is
      inconsistent with 'The Java Language Specification.'

      Float.toString and Double.toString has inconsistence with
      'The Java Language Specification' (Gosling, Joy, Steele).

        in 20.9.16 of the 'bible', they wrote:
       
       (cut) .. The magnutide is then represented as the integer
       part of a, as a single decimal digit, followed by '.'
       (\u002e), followed by decimal digits representing the
       fractional part of a, followed by the letter 'E' (\u0045),
       followed by a representation of n as a decimal integer,
       as produced by the method Integer.toString of one argument (20.7.12).

      where n is an integer 10^n <= argument < 10^(n+1).

        in 20.7.12, Integer.toString(int) is defined as toString(int, 10).

        in 20.7.13,

        (cut) .. If the first argument is negative, the first character of
        the result will be the character '-' (\u002d). If the first argument
        is not negative, no sign character appears in the result.

      So, Float.toString(1.0e+7f) must produce "1.0E7", but current JDK1.1
      Float.toString() produces "1.0E+7" (watch out on '+'.)

        Attachments

          Activity

            People

            Assignee:
            tlindholsunw Timothy Lindholm (Inactive)
            Reporter:
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: