Golang, what is the correct way to use math.max for two uint values?

This is what I do, it is extremely ugly. What is the correct way to use .Max math for 2 uint s?

thanks

vs .curView.Viewnum = uint (math.Max ​​(float64 (args.Viewnum + 1), float64 (vs .curView.Viewnum)))

+8
go
source share
1 answer

The main reason for math.Max is to ensure that some of the special cases of the IEEE floating point are handled correctly (positive and negative infinity, NaN and signed zeros).

These problems are not suitable for prime integers, so you can just use the obvious implementation. Something like:

 if args.Viewnum+1 > vs.curView.Viewnum { vs.curView.Viewnum = args.Viewnum+1 } 
+8
source share

All Articles