Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Arbitrary-precision arithmetic
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Applications== A common application is [[public-key cryptography]], whose algorithms commonly employ arithmetic with integers having hundreds of digits.<ref>{{cite web |url=https://arstechnica.com/news.ars/post/20070523-researchers-307-digit-key-crack-endangers-1024-bit-rsa.html |title=Researchers: 307-digit key crack endangers 1024-bit RSA |author=Jacqui Cheng |date=May 23, 2007}}</ref><ref>{{cite web|url=http://www.rsa.com/rsalabs/node.asp?id%3D2218 |title=RSA Laboratories - 3.1.5 How large a key should be used in the RSA cryptosystem? |access-date=2012-03-31 |url-status=dead |archive-url=https://web.archive.org/web/20120401144624/http://www.rsa.com/rsalabs/node.asp?id=2218 |archive-date=2012-04-01 }} recommends important RSA keys be 2048 bits (roughly 600 digits).</ref> Another is in situations where artificial limits and [[arithmetic overflow|overflows]] would be inappropriate. It is also useful for checking the results of fixed-precision calculations, and for determining optimal or near-optimal values for coefficients needed in formulae, for example the <math display=inline>\sqrt{\frac{1}{3}}</math> that appears in [[Gaussian integration]].<ref>{{cite report|url=https://tel.archives-ouvertes.fr/tel-00477243/en |title=Intégration numérique avec erreur bornée en précision arbitraire. Modélisation et simulation | author=Laurent Fousse | publisher=Université Henri Poincaré - Nancy I | language=fr | date=2006 }} </ref> Arbitrary precision arithmetic is also used to compute fundamental [[mathematical constant]]s such as [[pi|π]] to millions or more digits and to analyze the properties of the digit strings<ref>{{cite journal |author=R. K. Pathria |author-link=Raj Pathria |title=A Statistical Study of the Randomness Among the First 10,000 Digits of Pi |year=1962 |journal=Mathematics of Computation |volume=16 |issue=78 |pages=188–197 |url=https://www.ams.org/journals/mcom/1962-16-078/S0025-5718-1962-0144443-7/ |access-date=2014-01-10 |doi=10.1090/s0025-5718-1962-0144443-7|doi-access=free }} A quote example from this article: "Such an extreme pattern is dangerous even if diluted by one of its neighbouring blocks"; this was the occurrence of the sequence 77 twenty-eight times in one block of a thousand digits.</ref> or more generally to investigate the precise behaviour of functions such as the [[Riemann zeta function]] where certain questions are difficult to explore via analytical methods. Another example is in rendering [[fractal]] images with an extremely high magnification, such as those found in the [[Mandelbrot set]]. Arbitrary-precision arithmetic can also be used to avoid [[arithmetic overflow|overflow]], which is an inherent limitation of fixed-precision arithmetic. Similar to an automobile's [[odometer]] display which may change from 99999 to 00000, a fixed-precision integer may exhibit ''[[Integer overflow|wraparound]]'' if numbers grow too large to represent at the fixed level of precision. Some processors can instead deal with overflow by ''[[saturation arithmetic|saturation]],'' which means that if a result would be unrepresentable, it is replaced with the nearest representable value. (With 16-bit unsigned saturation, adding any positive amount to 65535 would yield 65535.) Some processors can generate an [[exception handling|exception]] if an arithmetic result exceeds the available precision. Where necessary, the exception can be caught and recovered from—for instance, the operation could be restarted in software using arbitrary-precision arithmetic. In many cases, the task or the programmer can guarantee that the integer values in a specific application will not grow large enough to cause an overflow. Such guarantees may be based on pragmatic limits: a school attendance program may have a task limit of 4,000 students. A programmer may design the computation so that intermediate results stay within specified precision boundaries. Some programming languages such as [[Lisp (programming language)|Lisp]], [[Python (programming language)|Python]], [[Perl]], [[Haskell (programming language)|Haskell]], [[Ruby (programming language)|Ruby]] and [[Raku (programming language)|Raku]] use, or have an option to use, arbitrary-precision numbers for ''all'' integer arithmetic. Although this reduces performance, it eliminates the possibility of incorrect results (or exceptions) due to simple overflow. It also makes it possible to guarantee that arithmetic results will be the same on all machines, regardless of any particular machine's [[Word (data type)|word size]]. The exclusive use of arbitrary-precision numbers in a programming language also simplifies the language, because ''a number is a number'' and there is no need for multiple types to represent different levels of precision.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)