Really large numbers

This is a discussion on Really large numbers within the C++ Programming forums, part of the General Programming Boards category; What type of variable would you use if the variable may be a sixty digit number....

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    5

    Really large numbers

    What type of variable would you use if the variable may be a sixty digit number.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Depends: do you need all sixty digits accurately, or is 1.45697e59 good enough? If the latter, there's always double; if the former, well, today we learn how to write a new data type. (Or learn how to use a library that already has done so.)

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,261
    Quote Originally Posted by Thinker View Post
    What type of variable would you use if the variable may be a sixty digit number.
    That depends on a whole heaps of answers to questions I can't be bothered asking today.
    A string perhaps.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    5
    It's the first tabstop. I;m doing a project euler problem where you have to add 100 50 digit numbers and i do not know what type of variable i need and i have gmp but reading the manual i do not know how to use it. Can some one help me out here. Thanks for any help provided.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Thinker View Post
    It's the first tabstop. I;m doing a project euler problem where you have to add 100 50 digit numbers and i do not know what type of variable i need and i have gmp but reading the manual i do not know how to use it. Can some one help me out here. Thanks for any help provided.
    You want to start reading the manual at page 17; the integer functions start at page 30.

  7. #7
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    Thinker: When I did that one, I just used char arrays.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to deal wth large numbers
    By bvgsrs in forum C++ Programming
    Replies: 2
    Last Post: 06-18-2007, 06:16 AM
  2. Handling Large Numbers
    By Xzyx987X in forum C Programming
    Replies: 2
    Last Post: 05-03-2004, 02:33 PM
  3. Using really big numbers!
    By Machewy in forum C++ Programming
    Replies: 11
    Last Post: 02-26-2004, 09:49 AM
  4. Help needed with VERY large numbers.
    By jwarner in forum C++ Programming
    Replies: 4
    Last Post: 01-18-2004, 11:01 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 05:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21