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

NumberUtils does not handle Long Hex numbers

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.2
    • Component/s: lang.math.*
    • Labels:
      None

      Description

      NumberUtils.createLong() does not handle hex numbers, but createInteger() handles hex and octal.
      This seems odd.

      NumberUtils.createNumber() assumes that hex numbers can only be Integer.
      Again, why not handle bigger Hex numbers?

      ==

      It is trivial to fix createLong() - just use Long.decode() instead of valueOf().
      It's not clear why this was not done originally - the decode() method was added to both Integer and Long in Java 1.2.

      Fixing createNumber() is also fairly easy - if the hex string has more than 8 digits, use Long.

      Should we allow for leading zeros in an Integer?
      If not, the length check is trivial.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sebb Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: