Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Programming with large integers

  1. Jun 18, 2006 #1
    Hi all, I'm doing a little programming at the moment using Dev-C++. I'm writing a windows program, and have all of the stuff like menus, dialog boxs etc sorted out, and now need to get onto the programming that makes the program achieve something. In the program I will be dealing with very large numbers (at first about 50 to 75 digit numbers, but I am hoping to extend this to around 150 digits once I have a working prototype). I will be doing mathematics with only integers, and will be doing large exponentials (a^(a very large number)), and modulus functions; however, I need near perfect precision, so no rounding. My questions are:
    1. Are there any libaries that I will need (or could use) that are not included in the standard windows API? (this may be a difficult question to answer, since this depends on IDE and updates but try your best anyway).
    2. How would I integrate them into my program? (Again a bit vague given that I haven't actually said what my program will do).

    Any help would be kind, thank you.
     
  2. jcsd
  3. Jun 18, 2006 #2

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    GMP is a commonly used big number library.


    It's not relevant here, but Java has built-in big number support -- BigInteger.
     
  4. Jun 19, 2006 #3
    Thank you:smile:
     
  5. Jun 27, 2006 #4
    I am a beginner in programming and I have no clue as to how to integrate GMP with my turbo C++ ( the manual wasn't very helpful ). Can someone give me a walkthrough please ?
     
  6. Jul 13, 2006 #5
    Yes it would be nice if anyone can help me on the same subject as well. I'm programming an encryption algorithm that requires working with enormous numbers (hundreds of thousands of digits or at least 500 digits to be practicle and less secure). How do I do that in Pascal or Visual Basic .NET? I need a -MANTISSA- that is that long and not a stupid 12 digit mantissa with a large exponent...

    Also since we're on the subject, how the heck do they perform operations on the keys in public key cryptography?
     
  7. Jul 13, 2006 #6

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Cryptography commonly uses libraries like GMP.. after all, most cryptography needs no more operations than exponentiation (mod some number) and multiplication.

    - Warren
     
  8. Jul 13, 2006 #7
    create your own integer class that handles N-bit binary numbers(easily converted so some N-digit decimal. Eberly has a pretty easy to read Integer class. One of the questions you need to ask is do you want to store the memory as a binary number or as a string of digits. When you decide on that then the operations them selves will be easy to code.
     
  9. Jul 14, 2006 #8
    And where can I get this GMP?

    So coding your own operations is the only way? No 'in-built' method? It would be mega slow that way rather than using assembly instructions.
     
  10. Jul 14, 2006 #9
    Get it here: GMP
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?