Thread: big numbers in C

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    3

    big numbers in C

    helloi am an amateur programmer in C!and i faced to a new problem and need help to resolve.this is my problem :i want to input big number(for example a number with more than 100 digits) in c.although long double can carry 18digits number,what data type i should use???in another words, i wand to make about 10000 psuedo random number with a random number maker and sort them using a sorting algorithm like shell sort.and i don't know how can i keep big numbers created with psuedo random number maker!!!also i don't want use arrays!so, what should i do????

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    There is currently no big number support in the common C standards. However, there are many bignum libraries available, such as The GNU MP Bignum Library.

    Hopefully you have the experience to know how to use libraries in conjunction with your compiler setup. If not, google around for tutorials.

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    If you want to do it withour a library, you'll have to use arrays. If all you really want is 10000 100-digit numbers sorted in a file, you could just create 10000 100-character strings of random digits and sort that.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    What is a number? "Impetuous fire"

    What is an array? "Ice and desire"

    No, that's Romeo and Juliet!
    (youth and maid)

    Numbers are just digits, arranged in order. WE give those digits meaning with concepts like the "number line" and "base 10" (2, 16, etc.).

    So numbers are made up of nothing but arranged digits - so an array of digits, be it type int or char, is perfectly in harmony with numbers.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    If you don't want to use arrays for such a program then you have 2 options:
    1. Throw away that requirement right now, or
    2. Throw away the entire problem and work on something completely different.

    Whether this is the last post on this thread or whether it goes on for 20 pages, one thing is certain; the above are your only viable two options. Pick one now so that you can move forward.
    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"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non prime numbers or composite numbers program.help plz!
    By danishzaidi in forum C Programming
    Replies: 10
    Last Post: 11-15-2011, 11:10 AM
  2. Replies: 3
    Last Post: 09-08-2010, 10:26 AM
  3. Replies: 5
    Last Post: 12-21-2007, 01:38 PM
  4. Comparing numbers to a list of numbers held in a text file
    By jmajeremy in forum C++ Programming
    Replies: 3
    Last Post: 11-06-2006, 07:56 AM
  5. Replies: 4
    Last Post: 03-03-2003, 03:52 PM

Tags for this Thread