Is there a way to round very large fractions like 3.7625745528893614e-83?

67 Views Asked by At

I have a large number of type float (3.7625745528893614e-83) which must go through the sigmoid function:

def sigmoid_one(x):#sigmoid computation function
 return (1/(1+math.e**(-x)))

,but after passing a large number (that is, a number with many characters after the decimal point) through the function, 0.5 is always obtained. For a solution, I wanted to try the round() function:

round(3.7625745528893614e-83,10)

, but after calculations it gives zero. Does anyone know a solution to this problem? maybe there is a replacement for the round () function or an alternative solution?

1

There are 1 best solutions below

0
On

For small x, the function exp(-x) is about the same as 1-x, so your function is approximately equal to 1/(2-x) which, for small x is about 1/2. So your program is working correctly.