Can you make an int greater than 2 ^ 31 - 1 (2,147,483,647)? Or is there a class you can use for that purpose? I can't use a double or a float.
Can you make an int greater than 2 ^ 31 - 1 (2,147,483,647)? Or is there a class you can use for that purpose? I can't use a double or a float.
unsigned long will increase the range somewhat but if you want to go higher than that you need something like http://swox.com/gmp/
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
C99 called just to say "long long".
Quzah.
Hope is the first step on the road to disappointment.
Thats C only and this is the c++ board.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Thanx for the awnsers, but i've downloaded the gmp software, and i don't understand how to use it. Could you maybe give a short explanation?
Quzah: I use classes and other C++ specific things in my program...
read the manual. It contains plenty of installation info for mingw and gcc. If you use MSVC you can use MinGW to build a lib that can be used with MSVC. Theres some instructions in the manual. For use of the library once built see the documentation and samples.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
You might want to search for other, C++ specific large integer classes, or even C++ wrappers for GMP, if they are out there.
From my experience, if you have a lot of number crunching to do, the C function-based syntax of GMP can be a royal pain (sorry Quzah).
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
Make your own integer class! Or use gmp if you don't want a mountain of extra work.
I abuse:
Borland C++ Builder 6 Enterprise Edition
Some people have no sense of humor. I guess I won't bother telling you that Java's long is 64 bits, since you wouldn't find that amusing either.Originally Posted by Stoned_Coder
Quzah.
Hope is the first step on the road to disappointment.
Not to mention that gcc supports long long in C++ and VS.NET supports some other weird name, and you can always use typedefs for portability.
VC++ supports __int64 for 64 bit integers.
Originally Posted by quzahHe merely mistook C99 for a telemarketer... honest mistake.Originally Posted by quzah
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
It seems everyone but Daved forgot to mention __int64, which is what I was going to suggest. If you need to get even bigger than that max you can use unsigned __int64.
Also, you can use my HugeFloat library for "unlimited" length numbers and rapid calculations. And it is as easy to use as a built-in type. Just click on that link or visit the library page on my site (see sig).
The reason I didnt mention __int64 is because it is m$ specific. I also knew that long long was a popular extension offered on gcc but that is specific to that compiler. Typedefs and conditional compilation could solve the problem but the more compilers you need to support the more like a spiders web your code looks. When you need numbers bigger than the language supports natively you should reach for a library if portability is any concern at all. There are numerous bignum libraries out there and there is a fair chance that a bignum library will be added to c++ at the next standard review.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
__int64 is not specific to Microsoft. __int64 is not one of the standard 5 integer types (according to C99 section 6.2.5 paragraph 4), but it is a legal ISO/ANSI extended integer type as defined by that same paragraph.