Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 461 Bytes

divide_by_zero.md

File metadata and controls

18 lines (15 loc) · 461 Bytes

divide_by_zero

What it does

Checks for division by zero. Allows 0 / 0 as a way to get nan.

Why this is bad

n / 0 equals math.huge when n is positive, and -math.huge when n is negative. Use these values directly instead, as using the / 0 way is confusing to read and non-idiomatic.

Example

print(1 / 0)
print(-1 / 0)

...should be written as...

print(math.huge)
print(-math.huge)