#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Europe
    Posts
    21
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    71
    Rep Power
    2
    Originally Posted by Highest bidder
    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.
    I know they have C/C++ libraries for arbitrarily large numbers.

    Here's an example of one - http://gmplib.org/
    Last edited by G4143; November 9th, 2012 at 10:11 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Europe
    Posts
    21
    Rep Power
    0
    Originally Posted by G4143
    I know they have C/C++ libraries for arbitrarily large numbers.

    Here's an example of one
    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...?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Europe
    Posts
    21
    Rep Power
    0
    i dont expect you to show me what to do. a good reference would be great if you happen to have any...
  8. #5
  9. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,549
    Rep Power
    2337
    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:
    Please don't be a help vampire!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Europe
    Posts
    21
    Rep Power
    0
    Originally Posted by ptr2void
    You mean, like, ** The one linked to right on the page provided?
    I've tried it already, too complicated for me :D anything easier? like a tutorial or something?
  12. #7
  13. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,387
    Rep Power
    1871
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0
    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.
  16. #9
  17. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,110
    Rep Power
    1803
    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.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0
    Originally Posted by clifford
    In VC++ long double is an 80 bit floating-point type, but in GCC x86 it is just a synonym for double.

    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.
    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).

    Comments on this post

    • clifford agrees : Quite possibly so. Always refer to the manual above trusting anything posted on a forum - even by me! ;-)

IMN logo majestic logo threadwatch logo seochat tools logo