File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Biginteger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Biginteger" Watch "Biginteger" New topic


Ali Gilani
Ranch Hand

Joined: Mar 01, 2002
Posts: 137
i wrote a program which exceeded the ranges of int so would print a constant value. At the Sun forums, they said to use BigInteger.

the code allows any number to be shown. i looked up the docs on the Math class but could not understand how to use any of its objects. for example

what does this mean ? BigInteger.valueOf(2)

and also, in the docs
multiply(BigInteger val) is present which says Returns a BigInteger whose value is (this * val) how do i use it in my programs? i mean what is the format?

Carl Pettersson
Ranch Hand

Joined: Sep 09, 2003
Posts: 73
BigInteger.valueOf(2) returns an BigInteger with the value 2. So, you declare two to be a BigInteger with the value 2.
Multiply() also returns the result of the operation, so you do

After this, myBigInt is a BigInteger with value 4, since you added it to itself, and 2 + 2 = 4.
Same goes for the other, such as BigInteger.multiply().
I agree. Here's the link:
subject: Biginteger
jQuery in Action, 3rd edition