How to handle numbers larger than the FLOAT type in Python-3.x

Asked

Viewed 55 times

0

I am having problems with the type of FLOAT data in Python. I have an algorithm that generates very large numbers, but the type FLOAT does not support them. See:

 35             denominadorP = fatorial(p)
 36 
---> 37         resultado = numerador / denominadorP
 38 
 39         return resultado

*OverflowError: integer division result too large for a float*

I was wondering if there is any library that can help me get around this. In case I write the numbers and write them in a file .txt

1 answer

-1

Since it will write to a txt file you could try solving it as follows resultado = str(numerador / denominadorP) f = open('resultado_denominador_fatorial.txt', 'w') #cria o arquivo com permissão de escrita f.write(resultado) f.close()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.