You are not logged in. Please login at www.codechef.com to post your questions!

×

# Storing very large number

 0 How can we store a very large number in c or c++ ? For example to calculate 99! (contains about 150 digits), how to do this in efficient manner ? asked 09 Jan '17, 23:25 37●5 accept rate: 0% you should use an array or string .you can handle even bigger than you are talking. (12 Jan '17, 19:43)

 2 @hmtupd123 You can use BIG INTEGERS in C++ using boost library. Here is an implementation of BIG INTEGERS in C++ using boost library (link). answered 09 Jan '17, 23:40 5★srd091 1.5k●1●11 accept rate: 42%
 2 Hi. The best answer to your question would be the blog post on codechef: https://discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial answered 12 Jan '17, 14:58 0★drp48603 25●2 accept rate: 0%
 0 For storing such large numbers you have to make use of the arrays or vectors which are containers that can store such large values .... and the number may pe interpreted as the digits seperated in different cells of the array. answered 09 Jan '17, 23:42 0 accept rate: 0%
 0 You can't store such a big number in any of the data types available in C or C++ but even if you want to store the value of say 99! or even 100! then have a look at this blog post of CodeChef. answered 10 Jan '17, 08:30 31 accept rate: 0%
 0 You have to use array to store such a large number.you can see the codechef tutorial for small factorial (FCTRL2).it is already discussed there.So I don't think i should repeat it here .you can easily check that tutorial.Or you can easily google small factorial codechef...you will get appropriate results.Here is the link https://www.codechef.com/wiki/tutorial-small-factorials Happy Coding:). answered 10 Jan '17, 08:33 1●1 accept rate: 0%
 0 I would suggest you to move to Java for this specific problem due to the availability of BigInteger. However , in C/C++, I would suggest you to read the implementation of BigInteger, and write something similar in C++, supporting only the operations that are common. answered 10 Jan '17, 22:03 467●6 accept rate: 10%
 0 maybe u should use string or array in this case u can handle even larger than what you are talking here. answered 12 Jan '17, 19:42 238●7 accept rate: 8%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "title")
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×167
×41

question asked: 09 Jan '17, 23:25

question was seen: 1,121 times

last updated: 12 Jan '17, 19:43