big number

This is a discussion on big number within the C++ Programming forums, part of the General Programming Boards category; Anyone know where I can find a compact implementation of "big number", about 300 lines or less? with simple operations ...

  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
    22,118
    How much do you care about efficiency? If not for the compactness requirement, the GMP is probably a good idea.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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,308
    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
    4,359
    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,308
    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
    4,359
    (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,308
    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
    4,359
    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, 02:31 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 01:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21