November 9th, 2012, 10:02 AM
Surpass unsigned long long
Hello i am new to programming and i was wondering if there is any way to go above the unsigned long long limit (about 18*10^18) and if yes how? thanks in adv.
November 9th, 2012, 10:08 AM
I know they have C/C++ libraries for arbitrarily large numbers.
Originally Posted by Highest bidder
Here's an example of one - http://gmplib.org/
Last edited by G4143; November 9th, 2012 at 10:11 AM.
November 9th, 2012, 10:17 AM
i already installed it, but i have no clue on how to use it... i was hoping for an example source code or more specific instructions maybe...?
Originally Posted by G4143
November 9th, 2012, 10:20 AM
i dont expect you to show me what to do. a good reference would be great if you happen to have any...
November 9th, 2012, 10:26 AM
You mean, like, the manual? The one linked to right on the page provided?
I ♥ ManiacDan & requinix
This is a sig, and not necessarily
a comment on the OP:
don't be a help vampire
November 9th, 2012, 10:42 AM
I've tried it already, too complicated for me :D anything easier? like a tutorial or something?
Originally Posted by ptr2void
November 9th, 2012, 10:55 AM
November 9th, 2012, 08:16 PM
What you refer to is typically called "BigInt". It basically does for ints what strings do for characters. There are various implementations and examples online. Try searching for "bigint c library"
If you choose one that is simple enough to accomplish your tasks, it will also have the advantage that it is easier to get it working. What exactly are your requirements? Packages like GMP offer many functions for highly complex or precise mathematical work but it might be too much for your needs.
For your original question (how to go beyond the limit), why not just use a double? You can make them (practically) as large a value as you want, but you will lose precision at high magnitudes because they are not integers.
November 10th, 2012, 03:28 AM
If you are "new" to programming, then you should realise that "experienced" programmers generally manage quite happily with numbers in the range supported by the built-in types. In fact 64 bit data type support is relatively new to the language, and 32 bit types are generally sufficient.
The point is that while greater range is supported by various "bigint" or arbitrary precision libraries, you should realise (as you have found) that such topics are not perhaps for the "novice". You have to understand the language fundamentals first.
Moreover when in real life did you ever really need a 19 digit number? Even if you need a number that large you seldom need it to 19 significant digits. Unless perhaps you are working at CERN!?
Note that greater range is provided by the double and long double floating-point data types, at the expense of precision. In VC++ long double is an 80 bit floating-point type, but in GCC x86 it is just a synonym for double. A 64-bit IEEE744 double precision float has a maximum range to 1x10^37 and a precision to at least 15 significant digits.
The x86 FPU's 80 bit FP type supported by VC++ but not GCC has wider range and is good for 20 significant figures so in fact has greater precision than long double as well.
Last edited by clifford; November 10th, 2012 at 03:30 AM.
November 10th, 2012, 03:49 AM
This information seems outdated. Check the GCC online manual. The normal format for long double is 80-bits. It can be optionally aligned to 96, 128 bits without changing the format using the -m128bit-long-double (although it still has the same precision as an 80-bit IEEE floating point number). Also you can use the flag -mlong-double-64 to specify you want a 64-bit long double (i.e. long double will be the same as double). The default is -mlong-double-80 (80 bit long doubles).
Originally Posted by clifford
Comments on this post