> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/d/detect_division_by_zero.md).

# Detect division by zero

The numerical system of Sidef evaluates `x/0` to `+/-Inf`.

```ruby
func div_check(a, b){
    var result = a/b
    result.abs == Inf ? nil : result
}

say div_check(10, 2)  # 5
say div_check(1, 0)   # nil (detected)
```

Alternatively, we can do:

```ruby
func div_check(a, b){
    Perl.eval("#{a} / #{b}")
}

say div_check(10, 2)  # 5
say div_check(1, 0)   # nil (detected)
```
