Results 1 to 2 of 2
  1. #1
    susan is offline Member
    Join Date
    Jul 2007
    Rep Power

    Default Fibonacci Algorithm

    I have 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.
    F(300) =2222322446294204455297398934619099672066669390964 99764990979600

    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.


  2. #2
    cachi is offline Member
    Join Date
    Jul 2007
    Rep Power


    Which makes me think that perhaps what they do is they create an array where each array element corresponds to a digit. That way you're not limited on size, per say. And with the many copy algorithms out there for increasing array size I wouldn't be surprised.

    However this is only a guess.
    I found the GNU Open Source BigInteger implementation which I would guess just about mimics it.

    GNU BigInteger

Similar Threads

  1. Printing Fibonacci Numbers
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 06:43 PM
  2. A Fibonacci printing program
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-28-2008, 07:26 PM
  3. Computing Fibonacci numbers recursively
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-22-2008, 08:20 PM
  4. Help with algorithm
    By susan in forum New To Java
    Replies: 1
    Last Post: 07-13-2007, 10:26 PM
  5. Help me with this algorithm
    By Marcus in forum Advanced Java
    Replies: 3
    Last Post: 07-02-2007, 01:30 PM

Posting Permissions

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