I am sure that everyone has used or heard of arbitrary-precision arithmetic which, as the name implies, can be used to represent a number to arbitrary (but finite) precision, thus going beyond the limitations of a single or double floating point number. It is not entirely clear how arbitrary precision arithmetic works (or at least I did not know before I wrote this blog post) so that is what I am going to blog about.
As a side note, there is another method of representing numbers known as symbolic computation which can really represent a number to infinite precision with very little memory usage. It does this by storing numbers using their symbolic representation, ex. pi*sin(3) is actually stored using the symbols pi, sin, and 3 and not the floating point approximation. Symbolic computation is mainly used for operations such as integration, differentiation, polynomial arithmetic, and simplification of algebraic expressions which intuitively makes sense because these operations all involve directly manipulating the actual symbols in the expression.
You can read more about symbolic computation at http://www.symbolicnet.org/toc.html
So back to arbitrary precision… First, we should understand how such a number is stored. The common implementation is to store digits (in a certain base) in a variable length array. Although this array can get arbitrarily large, it is still finite. The obvious reason for this is that your computer has a finite amount of memory. Another more subtle reason is that the indices used to reference array positions are themselves limited in size.
Advantages
The clear advantage is that we can represent a much larger range of numbers. This is useful for activities where we must have high precision such as cryptography or safety critical systems such as automated transportation. You wouldn’t want to be on a bullet train when an arithmetic overflow error occurs. Arbitrary precision also allows us to do very long calculations such as calculating pi to 1,241,100,000,000 digits. Another use is to determine how much error is generated by fixed precision operations as was discussed in class.
Disadvantages
Arbitrary precision must use operations which are implemented through software which makes it slower than fixed precision hardware operations. You may have encountered this if you have ever used bitwise operations. Doing a logical shift right (equivalent to integer division by 2) is faster than just dividing by 2 using the regular integer division operator. Thus arbitrary precision is usually only used when speed is not the main issue.
You can read more about arbitrary precision arithmetic at http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic






[…] MC Hammer’s Cardboard Box’s post on Arbitrary Precision Arithmetic […]