# NaN gates in julia? (from SIGBOBIK)

**URL:** <https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020>\
**Category:** General Usage\
**Created:** [April 11, 2019, 4:44am UTC](https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020 "2019-04-11T04:44:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [April 11, 2019, 4:44am UTC](https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020/1 "2019-04-11T04:44:58Z")

</div>

[Sigbovik](http://www.sigbovik.org/) produces every year a new edition, where they publish funny academic stuff. One article in the 2019 edition talks about the _NaN gates_, citing the document:

> People who work with real numbers are often taught that the number NaN is propagated through all expressions that use it (e.g. NaN−1 = NaN), like some kind of GNU Public Licensed number. This is a misconception. We already saw in the beautiful identities above that some expressions involving NaN do not result in NaN, like 1^NaN = 1 and compound(NaN, 0) = 0. But it is also the case that 1^inf = 1 and compound(inf, 0) = 0. Are there mathematical functions that distinguish between NaN and inf?  
> It turns out that there are! For example, the functions minNum and maxNum ([IEEE 754-2008, 5.3.1, p19]) take two arguments and return the min and max, respectively. They have the special, distinguished property that “if exactly one argument is NaN, they return the other. If both are NaN they return NaN.”

he implementation on julia of minNum and maxNum is, i think, the functions `Base.min` and `Base.max`, but, to my dismay, this happened:

```julia
julia> min(NaN,1)
NaN

```

My work is completely stopped because of this, and i blame on the compiler 😄 ,  
Anyway, is this ok?, i don’t care if it gets solved,it seems weird,but it can have some arcane uses and can improve the compliance with the floating point standard

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [April 11, 2019, 5:05am UTC](https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020/2 "2019-04-11T05:05:49Z")

</div>

There is a rather long discussion of that issue here:  
[https://github.com/JuliaLang/julia/issues/7866](https://github.com/JuliaLang/julia/issues/7866)

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [April 11, 2019, 5:12am UTC](https://discourse.julialang.org/t/nan-gates-in-julia-from-sigbobik/23020/3 "2019-04-11T05:12:05Z")

</div>

Also I heartily recommend the video accompanying the NaN gate paper:

[![](https://global.discourse-cdn.com/julialang/original/3X/a/3/a3c2157d9bb57b941a0db5726e0f62ec378bc4c2.jpeg "NaN Gates and Flip FLOPS") ](https://www.youtube.com/watch?v=5TFDG-y-EHs)
