This is what I do, it is extremely ugly.
What is the right way to use math.Max
for 2 uint s?
vs.curView.Viewnum =uint(math.Max(float64(args.Viewnum+1), float64(vs.curView.Viewnum)))
The main reason math.Max
exists is to ensure some of the special cases of IEEE floating point are handled correctly (positive and negative infinity, NaN
and signed zeroes).
These issues are not relevant for simple integers, so you may as well just use the obvious implementation. Something like:
if args.Viewnum+1 > vs.curView.Viewnum {
vs.curView.Viewnum = args.Viewnum+1
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With