Arithmetic operations on very long decimal places
3 answers
Use a language or library that supports arbitrary precision numbers ...?
In Python, ints will automatically advance to longs that are arbitrary sizes. You can use the second value to keep track of how many decimal places to move to get arbitrary floating point precision.
In Java, you can use the BigDecimal class , which is "arbitrary precision immutable decimal numbers".
I'm sure other examples exist in other languages.
+3
source to share
For languages that don't support computation on bignums, there are often libraries. For example, you can look at GMP . The docs will provide you with pointers to some typical algorithmic approaches.
Making bigum arithmetic quickly is difficult, so there are some rather convoluted algorithms ...
+3
source to share