Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import decimal
- # Set up a context with limited precision
- c = decimal.getcontext().copy()
- c.prec = 3
- # Create our constant
- pi = c.create_decimal('3.1415')
- # The constant value is rounded off
- print 'PI :', pi
- # The result of using the constant uses the global context
- print 'RESULT:', decimal.Decimal('2.01') * pi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement