Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1040

Javadoc for NumberUtils.isNumber() are not clear enough

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.3.2
    • 3.5
    • lang.math.*
    • None

    Description

      The Javadocs for NumberUtils.isNumber() do not clearly define what a valid number is. The current trunk documentation states:

      Checks whether the String a valid Java number.

      Valid numbers include hexadecimal marked with the 0x or 0X qualifier, octal numbers, scientific notation and numbers marked with a type qualifier (e.g. 123L).

      Non-hexadecimal strings beginning with a leading zero are treated as octal values. Thus the string 09 will return false, since 9 is not a valid octal value. However, numbers beginning with 0. are treated as decimal.

      Null and empty String will return false.

      In other Jira issues, I've seen people suggest that a number if valid if it can be used when assigning to a suitable Java type. E.g. "FOO" is a valid number if long x = FOO is valid (where long might be another numeric type). If this is the case, we should state it.

      Alternatively, the definition could be in terms of what is accepted by createNumber().

      Or we define exactly what we accept by specifying a grammar in the Javadocs.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            chtompki Rob Tompkins
            dmjones500 Duncan Jones
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment