CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006
    Posts
    25

    Data type question

    Im attempting to store a number into a variable, but I need a variable that would go high enough to store it. :-\

    10^16

    or

    100,000,000,000,000,000

    I've heard of C having an unsigned long long int, but does C++ have anything that could hold it?

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Data type question

    Quote Originally Posted by Campuschris
    Im attempting to store a number into a variable, but I need a variable that would go high enough to store it. :-\

    10^16

    or

    100,000,000,000,000,000

    I've heard of C having an unsigned long long int, but does C++ have anything that could hold it?
    It depends on the compiler. The C++ language has no predefined maximum integer size.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Re: Data type question

    Try out std::numeric_limits<int>/std::numeric_limits<long> to see if you achieve the range you want. But this would be platform/implementation specific and can vary.

    You can try libraries like BigInt/GMP that provide types with larger range and should help you.

  4. #4
    Join Date
    Jun 2004
    Location
    India
    Posts
    432

    Re: Data type question

    You can use __int64 variables. It is NOT part of standard and is microsoft specific, but may get your job done if you are working with Visual Studio.
    Last edited by UnderDog; October 15th, 2007 at 07:09 AM.
    Say no to supplying ready made code for homework/work assignments!!

    Please rate this post!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured