# Faster \`min\`,\`max\` for \`Float64|32\`

**URL:** <https://discourse.julialang.org/t/faster-min-max-for-float64-32/45464>\
**Category:** Internals & Design\
**Tags:** performance\
**Created:** [August 24, 2020, 5:46pm UTC](https://discourse.julialang.org/t/faster-min-max-for-float64-32/45464 "2020-08-24T17:46:57Z")\
**Posts on this page:** 1\
**Showing post:** 26

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [August 24, 2020, 10:50pm UTC](https://discourse.julialang.org/t/faster-min-max-for-float64-32/45464/26 "2020-08-24T22:50:52Z")

</div>

There doesn’t seem to be anything wrong with either min or max in isolation, but with minmax you force it do run both subtractions, while it seems like you can get away with changing either, e.g.:

```julia
function man(a::T, b::T) where {T<:FastFloat}
    a_b = a - b
    (signbit(a_b) | isnan(a)) ? b : a
end

```

doing away with one and the same subtraction, and fewer jumps/shorter assembly:

```julia
@code_native minmax(0.0, -0.0)

```

---

_[View the full topic](https://discourse.julialang.org/t/faster-min-max-for-float64-32/45464)._
