0

decimal module in Python.

There is no proper description about decimal module and Decimal() ion internet. import decimal x='3.3' y=3.3 a=decimal.Decimal(x) b=decimal.Decimal(a) c=decimal.Decimal(y) print(x,type(x)) print(y,type(y)) print(a,type(a)) print(b,type(b)) print(c,type(c)) Why a=3.3 and b=3.29999......... ? How does Decimal() function works >

26th May 2019, 4:06 PM
harshit
harshit - avatar
3 Réponses
+ 6
Try import decimal help(decimal) And here's a link to the non-existing proper description: https://docs.python.org/3/library/decimal.html 🤓
26th May 2019, 4:10 PM
Anna
Anna - avatar
+ 3
Also, you wrote it wrong. a and b are both 3.3. c is 3.299..., because it's been converted from a float (y), so the internal value of that float is taken. This is also explained in proper detail in the docs Anna linked.
27th May 2019, 2:48 AM
Kishalaya Saha
Kishalaya Saha - avatar
0
Anna I have already seen it but it is not proper. Also it is the only document which has some detail about decimal. Other websites shows functions in decimal module only.
26th May 2019, 7:10 PM
harshit
harshit - avatar