Thread: big number

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    266

    big number

    Anyone know where I can find a compact implementation of "big number", about 300 lines or less? with simple operations like add subtract mult. divide and power?

    thanks a lot!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    How much do you care about efficiency? If not for the compactness requirement, the GMP is probably a good idea.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I wrote not one, but two of them and they're available on my website in the Useful Classes section.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Did you ever fix those problems I told you about?

    Soma

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by phantomotap View Post
    Did you ever fix those problems I told you about?

    Soma
    Sorry I don't recall that, and I'm not aware of any current problems.
    Please drop me a PM if you can recall what they were.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    (I've just dropped by to check my email and stuff. I'm about to hit the sack.)

    At the time, you had relied on a few MSVC extensions related to template handling (e.g. not using `typename' to refer to an inherited type from a template).

    If you want, or if you just don't have a different compiler available, I'll take a look at them tomorrow.

    Soma

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Oh that's right - portability.
    I had a different compiler on my old PC that I used to use for increasing compatibility, but I haven't installed anything else on my new PC yet. I do remember taking care of much of it, so the bigint class should hopefully be fine, just probably not the varbigint class. My varbigint class uses an unnamed union iirc. I knew about the unportability of that when writing it, and yet somehow I just didn't particularly care.

    I'll get back into looking at portability again shortly. I'm away for the rest of the weekend.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I just sent you a PM or few. (It limits the number of characters.)

    Okay. I'm an idiot. I sent visitor messages instead of private messages. >_<

    Soma
    Last edited by phantomotap; 03-12-2010 at 04:26 PM. Reason: >_<

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    thanks iMalc, your bigint class is exactly what I was looking for...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. Replies: 6
    Last Post: 02-19-2009, 07:19 PM
  3. how to transform an aray of char in to a big number
    By transgalactic2 in forum C Programming
    Replies: 1
    Last Post: 01-03-2009, 06:41 AM
  4. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM