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

unsigned data types in Java

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs
    • x86
    • windows_xp



      Name: rmT116609 Date: 06/17/2003


      A DESCRIPTION OF THE REQUEST :
      I've seen that there have been several requests for unsigned integral types in Java, and you have generally blown these off in a fairly cavalier manner. Usually you report that these types are unnecessary and can be worked around. In some cases you are correct, and I can write code that chews up CPU time masking and shifting bits around, using the char type as an unsigned temporary bucket, etc. However, I'm dealing with a stream of bytes that contains numeric values. I have to grab a few bytes at a time and make a number out of them - an integer, a long, whatever. Obviously, some of those bytes may have the high-order bit set, not because they are negative numbers but because that's how they fit in that particular byte in the sequence. Java's insistence on treating each byte as a signed value, and therefore doing sign-extension for me, is a major pain.
      What this all boils down to is this: as a language vendor you should not be continually telling your user community that they are wrong when they request support from the language. Support the unsigned types because it is a reasonable thing to do, and stop pontificating. This is a major oversight in the language, and quite frankly, I'm amazed that you think it's okay to waste CPU run time rather than CPU compile time!

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Support the unsigned integral data types.
      ACTUAL -
      See above. Sometimes requires significant work-arounds.

      CUSTOMER SUBMITTED WORKAROUND :
      Bit shifting, masking.
      (Review ID: 187835)
      ======================================================================

            darcy Joe Darcy
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: