Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import decimal
- with decimal.localcontext() as c:
- c.prec = 2
- print 'Local precision:', c.prec
- print '3.14 / 3 =', (decimal.Decimal('3.14') / 3)
- print
- print 'Default precision:', decimal.getcontext().prec
- print '3.14 / 3 =', (decimal.Decimal('3.14') / 3)
Advertisement
Add Comment
Please, Sign In to add comment