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

NumberUtils.isNumber() Should Return True for Valid Number with a Trailing Decimal Place

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.5
    • Component/s: lang.math.*
    • Labels:
      None
    • Environment:

      Windows XP SP3, Intel CPU

      Description

      NumberUtils.isNumber() should return true for a valid number ending in a trailing decimal place; e.g., "2." should be considered a number because new BigDecimal("2.") works fine. This could be done by adding the code below after line 1444, which is the if (chars[i] == 'e' || chars[i] == 'E') block.

      if (chars[i] == '.') {
      if (hasDecPoint || hasExp)

      { // two decimal points or dec in exponent return false; }

      return foundDigit; // single trailing decimal point after non-exponent is ok
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              crompot Chris Rompot
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: