Get maximum int64 value using 2's complement arithmetic golang

135 views Asked by At

How to get maximum int64 value using 2's complement arithmetic in golang

I need to compare incoming int64 value with maximum value for int64 (not using math package). I don't want to use math.MaxInt64 value, I know that where are some method for int

1

There are 1 answers

0
Nikita On

Found: const MaxInt64 := int64(^uint64(0) >> 1) or const MaxInt64 = 1<<63 - 1, also const MaxUint = ^uint64(0)