https://godbolt.org/z/1zjKP6z8q
edit:
A mixture of the two approaches possibly outperforms both:
https://godbolt.org/z/WxGWPvYTs
edit2:
Doh, of course to be be correct for the min approach, you need to use unsigned. Does not change the performance though.
https://godbolt.org/z/1zjKP6z8q
edit:
A mixture of the two approaches possibly outperforms both:
https://godbolt.org/z/WxGWPvYTs
edit2:
Doh, of course to be be correct for the min approach, you need to use unsigned. Does not change the performance though.