GeeCON Prague 2014*
The moose likes Java in General and the fly likes Addition of 256bit unsigned integers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Addition of 256bit unsigned integers" Watch "Addition of 256bit unsigned integers" New topic
Author

Addition of 256bit unsigned integers

Chan Lee
Greenhorn

Joined: Sep 02, 2008
Posts: 25
Hi friends,

I need a help.
Can anyone tell how to add two 256bit/512bit/1024bit unsigned integers in java?
(or)
Can anyone give some idea? please help me.
Peter Lawrey
Ranch Hand

Joined: Dec 21, 2008
Posts: 62
You can use BigInteger.
This supports addition and other operations of any precision integers.
Chan Lee
Greenhorn

Joined: Sep 02, 2008
Posts: 25
Originally posted by Peter Lawrey:
You can use BigInteger.
This supports addition and other operations of any precision integers.



Thank you Peter, i know that we can use BigIntegers concept. But, I'm unable to get any idea regarding this problem.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
Look in the API documentation; it is really easy.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11356
    
  16

a 256-bit number is just a number. The BigInteger class has several constructors that take different objects. How is your number stored? Probably the simplest would be to convert it to a string and use that.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Chan Lee
Greenhorn

Joined: Sep 02, 2008
Posts: 25
r
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
"budha",
may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.


Ping & DNS - my free Android networking tools app
 
GeeCON Prague 2014
 
subject: Addition of 256bit unsigned integers