Bonjour
J'aimerai savoir comment augmenter la précision de racine de 2 dans un script.
J'ai essayé ça mais ça:
mais j'ai ce message d'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 from decimal import * from math import sqrt getcontext().prec=10000 r2=Decimal(sqrt(2)) x=Decimal(5) print r2/x
Comment résoudre ce problème s'il vous plait.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 >>> Traceback (most recent call last): File "<module3>", line 6, in <module> File "C:\Documents and Settings\IANTE\Mes documents\AmiensPython 2.0\Portable\App\lib\decimal.py", line 652, in __new__ "First convert the float to a string") TypeError: Cannot convert float to Decimal. First convert the float to a string >>>
Merci
Partager