Thread: Large Variables

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    4

    Large Variables

    I was wondering if there was any way to store very large variables? Larger than a Long would let you hold.

  2. #2
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    double?

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    4
    I was thinking something more along the lines of an infinate variable.

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    hmm the best i can think of is to define a macro with the value..

    Code:
    #define PI =    3.14blah blah
    but it will only store that number and connect be changed..

    maybe some more expeirienced programmers know a better way.
    Last edited by mrafcho001; 03-22-2005 at 04:47 PM.

  5. #5
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Would you care to elaborate just a tad more? How large a number are you talking about?

    Currently, the largest built-in types are commonly 64-bits, however there are lots of classes available in assorted places online that afford the use of arbitrary length integers (you'll find a lot fewer that support floating point numbers).

  6. #6
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Quote Originally Posted by mrafcho001
    hmm the best i can think of is to define a macro with the value..

    Code:
    #define PI =    3.14blah blah
    but it will only store that number and connect be changed..

    maybe some more expeirienced programmers know a better way.
    That #define statement should not have an equal sign and even if you hard-coded a numeric value, it would still be subject to the limits of the compiler.

  7. #7
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    You can use an INT64 which is quite large.
    If you need arbitrary prescicion then you could check out http://www.swox.com/gmp/

  8. #8
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Quote Originally Posted by MadCow257
    You can use an INT64 which is quite large.
    If you need arbitrary prescicion then you could check out http://www.swox.com/gmp/

    WOW! INT64 is huge!

  9. #9
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Although _int64 is freaking ENORMOUS, if you want to keep getting bigger and bigger, you and just convert a string of tons of numbers to an int, I suppose.

  10. #10
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You might also consider using the BigInt class.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  11. #11
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    You reminded me of a class I wrote called HugeFloat. While it, a singleton effort, surely cannot hold a candle to GMP or any other collaboration, the code is simple and you might find it educational or interesting to mull over.

    I just started a thread about it here. Let us know how things work out for you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  2. Creating local variables in a program?
    By fl0at in forum C Programming
    Replies: 5
    Last Post: 01-04-2008, 07:34 PM
  3. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  4. Computing Large Values
    By swbluto in forum C++ Programming
    Replies: 8
    Last Post: 04-07-2005, 03:04 AM
  5. functions to return 2 variables?
    By tim in forum C Programming
    Replies: 5
    Last Post: 02-18-2002, 02:39 PM