DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: dealing with large numbers

1. Registered User
Join Date
Jul 2004
Posts
10

## dealing with large numbers

Hi,
I'm supposed to calculate some rediculously large numbers (like 46^75). I know these numbers are definitely way beyond the capacity of doubles. Can anyone suggest a variable type to do that? Thanks.

2. Registered User
Join Date
Jul 2004
Posts
83
instead of double, use long. ex:
long a=watever

3. INTERESTING
Join Date
May 2004
Posts
219
That isn't quite long enough

Code:
`BigDecimal d = new BigDecimal(Math.pow(46,75));`
Code:
```50914018510357733692393581562939574405608588594976882332374683237310907296616337
624639423841109727047053358355569614346256384```

4. Registered User
Join Date
Jul 2004
Posts
10
Drain,
Thanks a bunch! Now another question is how do I raise this number to the power of 1/75? I know this sounds stupid, but my project requires such silly computations. so I need to do
(46^75)^(1/75), which will be 46 again. I know that BigInteger has a function called pow() but it only takes int. Any idea?

5. INTERESTING
Join Date
May 2004
Posts
219
Well, n^(1/a) is equivalent to the a root of n. Unfortunately, BigInteger doesn't have a method for that either... I'm not sure how you would do that.

6. Banned Member
Join Date
Feb 2004
Posts
808

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise