You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The package math/ints would functions for common operations on integers:
Max(a, b int) int
Min(a, b int) int
Abs(value int) int
Pow(a int, b uint) int
Rationale: although Max, Min and Abs are trivial to implement, they are used so often they probably warrant being in the standard library.
The list above is not meant to be exhaustive, but more of a starting point. The package could also contain constants IntMax, IntMin, Int64Max, Int64Min.
The text was updated successfully, but these errors were encountered:
Thanks for the links. Both are useful, although it seems the discussion diverges quickly into generics. I can't really find the reason for why a separate package for these functions would be a bad idea.
I have my own package ints of course, so it doesn't really matter that much. It's just strange this is not present in the Go stdlib given its common use. It's weird when learning Go and still weird after two years of using it.
Having these function will probably also reduce the complaints about the lack of generics a bit.
The package
math/ints
would functions for common operations on integers:Rationale: although Max, Min and Abs are trivial to implement, they are used so often they probably warrant being in the standard library.
The list above is not meant to be exhaustive, but more of a starting point. The package could also contain constants
IntMax
,IntMin
,Int64Max
,Int64Min
.The text was updated successfully, but these errors were encountered: