United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4504839 : Java libraries should provide support for unsigned integer arithmetic

Details
Type:
Enhancement
Submit Date:
2001-09-19
Status:
Closed
Updated Date:
2012-05-07
Project Name:
JDK
Resolved Date:
2012-05-07
Component:
core-libs
OS:
solaris_8,generic,windows_xp,windows_2000
Sub-Component:
java.lang
CPU:
itanium,x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,1.4.0_02,1.4.1,1.4.2
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

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.
                                     
2012-01-21
PUBLIC COMMENTS

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

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

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

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-09-02
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
                                     
2003-09-08
WORK AROUND

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



Hardware and Software, Engineered to Work Together