Gox
01-23-2007, 04:20 PM
Hi,
I've written a little program to calculate Fibonacci numbers up to F(300). If you have knowledge of Fibonacci, you'll know that the number get very large, very quickly.
i.e F(300) =222232244629420445529739893461909967206666939096499764990979600
Obviously this number can't be stored in an Int or Long etc. To solve the issue I've used Java's BigInteger Class to store these numbers. It works well. However, I would like to understand how BigInteger works "under the hood". Does it store the numbers as byte arrays, as Strings etc?
Java's API for BigInteger doesn't seem to specify how it works in terms of how it stores numbers, just how to use the class. If anyone can explain, or point me in the direction of a write up on how BigInteger stores it's numbers that would be quite helpful.
Thanks,
Gox
I've written a little program to calculate Fibonacci numbers up to F(300). If you have knowledge of Fibonacci, you'll know that the number get very large, very quickly.
i.e F(300) =222232244629420445529739893461909967206666939096499764990979600
Obviously this number can't be stored in an Int or Long etc. To solve the issue I've used Java's BigInteger Class to store these numbers. It works well. However, I would like to understand how BigInteger works "under the hood". Does it store the numbers as byte arrays, as Strings etc?
Java's API for BigInteger doesn't seem to specify how it works in terms of how it stores numbers, just how to use the class. If anyone can explain, or point me in the direction of a write up on how BigInteger stores it's numbers that would be quite helpful.
Thanks,
Gox