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

Integer.toString should have unsigned option

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.0
    • core-libs
    • sparc
    • solaris_2.5

      Integer.toString always prints the argument as signed, even if the radix
      is 8 or 16. Whilst this might occasionally be useful, I would argue this
      is not the common case, and that for octal or hex output it is more
      likely that the client wants unsigned output.

      As an example,
        
          System.out.println(Integer.toString(0xcafebabe, 16));

      confusing prints out

          -35014542

      which is made more confusing by the fact there isn't an alpha-hex digit
      in sight!

      If nothing else, how about a routine
      Integer.toUnsignedString()
      or some such?

      -- Jon

            hongzh Hong Zhang
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: