|
-
October 11th, 2007, 08:25 PM
#1
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?
-
October 11th, 2007, 09:05 PM
#2
Re: Data type question
 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
-
October 15th, 2007, 03:14 AM
#3
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.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
October 15th, 2007, 07:07 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|