JDK-4504839 : Java libraries should provide support for unsigned integer arithmetic
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.0,1.4.0_02,1.4.1,1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,solaris_8,windows_2000,windows_xp generic,solaris_8,windows_2000,windows_xp
  • CPU: generic,x86,itanium
  • Submitted: 2001-09-19
  • Updated: 2021-12-27
  • Resolved: 2012-05-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b25Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
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

Comments
SUGGESTED FIX See attached webrev.
21-01-2012

PUBLIC COMMENTS See http://hg.openjdk.java.net/jdk8/tl/jdk/rev/71200c517524
21-01-2012

EVALUATION Responding to a JDC comment, addressing the high order bits of a double width integer multiply is the subject of bug 5100935.
28-11-2005

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
02-09-2004

PUBLIC COMMENTS Request to provide unsigned arithmetic on 32 and 64 bit integers.
02-09-2004

EVALUATION These methods, or another mechanism, should be used to provide unsigned arithmetic. ###@###.### 2001-09-19 Name: jd38982 Date: 02/04/2002 This feature has been added for Tiger release ====================================================================== Decommitting from Tiger, issue should be addressed in a future release. ###@###.### 2003-09-08
08-09-2003

WORK AROUND ###@###.### 2002-10-02 You can use both Java classes java.math.BigInteger and java.math.BigDecimal for large number support. ---
02-10-2002