# Division by zero runs without warning -\> complicates finding bugs

**URL:** https://discourse.julialang.org/t/division-by-zero-runs-without-warning-complicates-finding-bugs/113441
**Category:** Internals & Design
**Tags:** question
**Created:** [April 24, 2024, 12:33pm UTC](https://discourse.julialang.org/t/division-by-zero-runs-without-warning-complicates-finding-bugs/113441 "2024-04-24T12:33:55Z")
**Posts on this page:** 1
**Showing post:** 20

<div class="post-metadata">

### Author: ![moble](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moble/32/23535_2.png) [@moble](https://discourse.julialang.org/u/moble)
#### Post date: [May 2, 2024, 3:26am UTC](https://discourse.julialang.org/t/division-by-zero-runs-without-warning-complicates-finding-bugs/113441/20 "2024-05-02T03:26:47Z")

</div>

> [@StefanKarpinski](#):
>
> the alternative is emitting actual instructions after _every single floating-point operation_ to check if it produced an infinity or a NaN and then explicitly throwing an exception in software if they did. This would have absolutely horrible performance implications…

But when you do have a problem, you go back and look for it, at which point performance is not so important. Fortunately, with Julia you can usually plug in a different type that acts just like `Float64` or whatever, except that it checks for bad conditions. @brianguenter suggested a `NaNCheck` type [here](https://discourse.julialang.org/t/treating-nan-as-error-helping-debugging/36933/9), which I’ve used to track down NaNs in my code.(\*) I keep meaning to put that together as a little package, because there [have been](https://discourse.julialang.org/t/treating-nan-as-error-helping-debugging/36933) a [few times](https://discourse.julialang.org/t/nan-detector/55024) when [this issue](https://discourse.julialang.org/t/nan-detector/55024) has crept up.

Along the same lines is [SaferIntegers.jl](https://github.com/JeffreySarnoff/SaferIntegers.jl), which may be more specifically relevant to the OP.

* * *

(\*) I’ve also found it useful to initialize arrays with `NaNCheck{Float64}(NaN)`, so that I can find when I used uninitialized data.

---

_[View the full topic](https://discourse.julialang.org/t/division-by-zero-runs-without-warning-complicates-finding-bugs/113441)._
