<p>When doing calculations on very large numbers where integral data types such as double or int64 falls short, a separate class to handle such large numbers may be needed.  </p>

<p>Does anyone care to offer an efficient algorithm on how best to do this?</p>

[{'answer_id': 26116, 'author': 'jjnguy', 'author_id': 2598, 'author_profile': 'https://Stackoverflow.com/users/2598', 'pm_score': 2, 'selected': False, 'text': "<p>Using the built-in features of a language work for me.</p>\n\n<p>Java has <code>BigInteger</code> and <code>BigDecimal</code>, and Python automagicaly switches to an object similar to Java's if a number gets out of the range of an <code>integer</code> or whatnot.</p>\n\n<p>As for other languages though, I have no idea.</p>\n\n<p>I hate re-inventing the wheel.</p>\n"}, {'answer_id': 26133, 'author': 'Pascal', 'author_id': 1311, 'author_profile': 'https://Stackoverflow.com/users/1311', 'pm_score': 4, 'selected': False, 'text': '<p>There are 2 solutions to your problem:</p>\n\n<ul>\n<li><p><strong>Easy way:</strong>\nUse an external library such as \'<a href="http://gmplib.org/" rel="noreferrer">The GNU MP Bignum Library</a> and forget about implementation details.</p></li>\n<li><p><strong>Hard way:</strong>\nDesign your own class/structure containing multiple higher order datatypes like double or int64 variables and define basic math operations for them using operator overloading (in C++) or via methods named add, subtract, multiply, shift, etc. (in JAVA and other OO languages). </p></li>\n</ul>\n\n<p>Let me know if you need any further help. I have done this a couple of times in the past.</p>\n'}, {'answer_id': 30093, 'author': 'samy', 'author_id': 3204, 'author_profile': 'https://Stackoverflow.com/users/3204', 'pm_score': 2, 'selected': False, 'text': "<p>Doing your own BigNum library is complicated, so i'd say like jjnguy. Use whatever your language offers as libraries.</p>\n\n<p>In .net, reference the VisualJ dll as they contain the BigInteger and BigDecimal classes. You should however be aware of some limitations of these libraries, like the lack of a square root method, for example.</p>\n"}, {'answer_id': 273948, 'author': 'HanClinto', 'author_id': 26933, 'author_profile': 'https://Stackoverflow.com/users/26933', 'pm_score': 2, 'selected': False, 'text': '<p>You\'re asking about <a href="http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic" rel="nofollow noreferrer">arbitrary-precision arithmetic</a>, a subject on which <a href="https://rads.stackoverflow.com/amzn/click/com/1597491128" rel="nofollow noreferrer" rel="nofollow noreferrer">books have been written</a>. If you just want a simple and fairly efficient BigNum library for C#, you might want to check out <a href="http://www.codeplex.com/IntX" rel="nofollow noreferrer">IntX</a>.</p>\n'}, {'answer_id': 2673361, 'author': 'vzczc', 'author_id': 224, 'author_profile': 'https://Stackoverflow.com/users/224', 'pm_score': 4, 'selected': True, 'text': '<p>In C# 4.0 use the <a href="http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx" rel="noreferrer">BigInteger type</a></p>\n'}]
['https://Stackoverflow.com/questions/26094', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/224/']