focus/utils/math.go

11 lines
160 B
Go
Raw Normal View History

2019-05-20 11:12:38 +00:00
package utils
var bit = uint(32 << (^uint(0) >> 63))
var bitsub1 = bit - 1
2019-12-22 16:43:25 +00:00
// AbsInt
2019-05-20 11:12:38 +00:00
func AbsInt(n int) uint {
y := n >> bitsub1
return uint((n ^ y) - y)
}