I am trying to use UDF in xlwings and I want to achieve required precision as both libraries Python Decimal and mpmath allows for this. I am calculating 2 ^ 0.5 with following functions:
@xw.func
def fce_2(x, y):
import decimal
from decimal import Decimal
decimal.getcontext().prec = 100
z = Decimal(x)** Decimal(y)
return z
This returns 1,4142
AND
@xw.func
def fce_1(x, y):
from mpmath import mp
mp.dps = 100
z = mp.mpf(x)** mp.mpf(y)
return z
Returns 1,414213562 None of them returns the required number of decimal places which should be 100.