I don't know if it's important to you, but your Max[float64] isn't
compatible with math.Max in the standard library.
For example, Max[float64](NaN, 1) returns 1 rather than NaN.
On Tuesday, 22 March 2022 at 16:58:40 UTC+1 esi...@gmail.com wrote:
> I found a working version meantime.
>
> // Max r
I found a working version meantime.
// Max returns the bigger value between two numbers.
func Max[T constraints.Ordered](x, y T) T {
if x > y {
return x
}
return y
}
// Abs returns the absolut value of x.
func Abs[T constraints.Signed | constraints.Float](x T) T {
if x < 0 {
return -x
}
return x
some details: https://github.com/golang/go/issues/48918
On 3/18/22, Endre Simo wrote:
> Now that generics are officially supported, I was checking in the Go source
>
> if there are some generic implementation of utility methods like Abs, Min,
> Max etc, but I couldn't find it other than this
> pr
Now that generics are officially supported, I was checking in the Go source
if there are some generic implementation of utility methods like Abs, Min,
Max etc, but I couldn't find it other than this
proposal https://github.com/golang/go/discussions/48287.
Anyone knows if something related has b