I don't know why it's not part of the standard library, but here is a piece
of code that does the job. (It's written in a slightly roundabout way to
make sure that the constants are untyped.)
const BitsPerWord = 32 << (^uint(0) >> 63) // either 32 or 64
const (
MaxInt = 1<<(BitsPerWord-1) - 1 // either 1<<31 - 1 or 1<<63 - 1
MinInt = -MaxInt - 1 // either -1 << 31 or -1 << 63
MaxUint = 1<<BitsPerWord - 1 // either 1<<32 - 1 or 1<<64 - 1
)
On Friday, February 23, 2018 at 2:15:44 AM UTC+1, Jason Gade wrote:
>
> I see that the math/bits package has a UintSize constant, and math has
> Max<Txx> types. Why doesn't math have MaxInt and MaxUint?
>
> Yes, I know that these are derivative by themselves, but can they be
> included in the standard library without breaking the Go Compatibility
> promise?
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.