In python why result become zero when i multiply anyother value with 5.55375797812e+28 .
But we all Know Python accept a very big range value.
Asked
Active
Viewed 2,347 times
-2

Ravi Singh
- 93
- 2
- 12
-
[`decimal.Decimal`](https://docs.python.org/2/library/decimal.html#decimal-objects), your question is however off topic for stackoverflow as you are asking to find some tool for you. – Tadhg McDonald-Jensen Apr 10 '16 at 16:08
-
its not working bro i used it...... – Ravi Singh Apr 11 '16 at 03:34
1 Answers
3
You can use the built-in decimal
library.
import decimal
decimal.getcontext().prec = 46 # Change 46 to the precision you want.
result = decimal.Decimal(1.6) / decimal.Decimal(7)
print(result)
Decimal('0.2285714285714285841168345671446461762700762068')
Keep in mind that when you have to use the set precision you always need to enclose the number in decimal.Decimal()
and you will always get Decimal()
returned.

Ciprum
- 734
- 1
- 11
- 18