aspose file tools
The moose likes Beginning Java and the fly likes Dealing with integers bigger than 9223372036854775807 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Dealing with integers bigger than 9223372036854775807" Watch "Dealing with integers bigger than 9223372036854775807" New topic
Author

Dealing with integers bigger than 9223372036854775807

Grant Shannon
Greenhorn

Joined: Mar 01, 2006
Posts: 3
Hey all,

I'm writing a small application that is determining probabilities and in the process is utilizing factorials. Thus, as soon it encounters a situation where it needs to calculate 21! or more - i have a problem.

long is no longer cutting the mustard! I had thought that BigLong or BigInteger might be the answer, but having just glanced at them they seem to be more about precision than a simple increase in the size of the value they represent.

I'm positive there is an answer to my problem, I'm just hoping its a simple solution. Any help would be wonderful.
Steve Fahlbusch
Ranch Hand

Joined: Sep 18, 2000
Posts: 491
    
    2

Grant,

I had no problem writing a factorial method usint BigInteger that easily works generates factorials of 21 and 22 and above.

What have you tried with BigInteger that didn't work.
Grant Shannon
Greenhorn

Joined: Mar 01, 2006
Posts: 3
Well, to be honest - i haven't tried anything with BigInteger yet.
I looked at it in the API after encountering the helpful looking class name, but it didn't seem to suggest that it could deal with integers larger than 9223372036854775807 explicity.
However, now that you say it can, i will happily go and experiment.

Thanks.
Grant Shannon
Greenhorn

Joined: Mar 01, 2006
Posts: 3
Thanks a bunch Steve - BigInteger worked a treat
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Dealing with integers bigger than 9223372036854775807
 
Similar Threads
ints, floats and doubles
help='(
Autoincrement or not, how to ++
Cultural errata in HFSJ
More Code Concepts...