When I do floating point division in Python, if I divide by zero, I get an exception:
>>> 1.0/0.0
Traceback (most recent call last):
File \"
You could try using the 'decimal' module:
>>> from decimal import *
>>> setcontext(ExtendedContext)
>>> inf = Decimal(1) / Decimal(0)
>>> print(inf)
Infinity
>>> neginf = Decimal(-1) / Decimal(0)
>>> print(neginf)
-Infinity
>>> print(neginf + inf)
NaN
>>> print(neginf * inf)
-Infinity
>>> print(dig / 0)
Infinity