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

Java libraries should provide support for unsigned integer arithmetic

    Details

    • Subcomponent:
    • Resolved In Build:
      b25
    • CPU:
      generic, x86, itanium
    • OS:
      generic, solaris_8, windows_2000, windows_xp
    • Verification:
      Verified

      Description

      There are many cases where unsigned integer arithmetic is preferable and more convenient to work with than the signed integer arithmetic provided by Java. Unsigned arithmetic on 32 bit and 64 integers could be provided by adding static methods to Integer and Long, e.g. Integer.addUnsigned, Integer.divideUnsigned, etc.

      Name: jd38982 Date: 02/04/2002

      Customer Problem Description:
      jdk doesn't support unsigned long value. The "long" data type is a
      signed long data type in jdk1.3 or jdk1.4. That means for positive number, it only support up to 63 bits. If a positive number that is bigger than 63
      bits, it becomes a negative number. We need jdk to support an unsigned
      long value.


      ###@###.### 2002-09-20

      Name: rmT116609 Date: 08/14/2003


      A DESCRIPTION OF THE REQUEST :
      Java primitive number are byte (8 bits signed), short (16 bits signed), int (32 bits signed) and long (64 bits signed). It may be the time for java to add capability to optimal arithmetic with 128 bits signed integers because 64 bits processors will make 128 bits operation as fast as actual 64 bits. We propose the keyword 'huge' and also the associated class Huge. Moreover algorithm like digest (SHA, MD5) and cryptography need to make operation on block of 128 bits size !



      JUSTIFICATION :
      It will help making computation on CRC, Error Correcting Code, Digest (MD5) impressively faster than with BigInteger class.
      It is a natural evolution like for type long in a 32 bits environnement.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
        To have more choice for choosing type of integers to make arithmetic with java.
        To have a powerful type to make 128 bits computation which will be JVM optimized.


      ACTUAL -
        To make arithmetic with more than 63 bits unsigned and 64 bits signed you have to use the class BigInteger which is far more slower than using primitive type.
      Instead you have to code your own 128 bits computation instrument which cannot be as optimized as a native primitive java type !


      CUSTOMER SUBMITTED WORKAROUND :
      Using java.math.BigInteger
      (Review ID: 199026)
      ======================================================================
      Discussion of API for this RFE:
      http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-January/008926.html

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                darcy Joe Darcy
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: