A set of Python 3 defined functions. They can provide high decimal precision calculations using numbers in str
format. The algorithms used are the same as those used when performing the calculations by hand. All using Python 3 built-in functions.
If you don't have the high_precision_calculations.py
script placed in your working directory, the functions can be imported, for example, by using
import sys
path = "<path to the folder where the script is stored>"
sys.path.insert(0, path)
import high_precision_calculations
As a practical example, for calculating the value of the golden ratio
divide_str(sum_str("1", sqrt_str("5", decimal_prec=50)), "2", decimal_prec=50)
or
divide_str(sum_str("1", sqrt_str("5", 50)), "2", 50)
which should return
'1.61803398874989484820458683436563811772030917980576'
To see the output of the functions in this example using 15000 decimals see the file phi_15000_decimals.txt
num_decims(num)
max_num_decims(num1, num2)
num_zeros_init(num)
num_zeros_end(num)
del_decim_zeros(num)
decim_modif_str(num1, num2)
make_pairs(txt)
Function name | Use |
---|---|
sum_str(num1, num2) |
Addition. |
subt_str(num1, num2) |
Subtraction. |
multiply_str(num1, num2) |
Multiplication. |
divide_str(dividend, divider, decimal_prec=16) |
Division. |
sqrt_str(num, decimal_prec=16) |
Square root. |
power_str(num, powr) |
Power (the argument "powr" must be a positive integer). |