Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # credit for this goes to the author
- # of The Python Standard Library by example
- # Jesse Noller, Python Core Developer and PSF Board Member
- # Book can be purchased on amazon, it is also
- # on the oreilly bookshelf and may be at your
- # library. I'm only reprinting the code example
- # here because I'm working on this stuff as a
- # student of the Python Programming language.
- # Thanks Jesse Noller for such a good book.
- import decimal
- for value in ['Infinity', 'NaN', '0']:
- print decimal.Decimal(value), decimal.Deciamal('-' + value)
- print
- # Math with infinity
- print 'Infinity + 1:', (decimal.Decimal('Infinity') + 1)
- print '-Infinity + 1:', (decimal.Decimal('-Infinity') + 1)
- # Print comparing NaN
- print decimal.Decimal('NaN') == decimal.Decimal('Infinity')
- print decimal.Decimal('NaN') != decimal.Decimal(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement