You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

math.go 347B

1234567891011121314151617181920212223
  1. package common
  2. // Abs returns the absolute value of x.
  3. func Abs(x int64) int64 {
  4. y := x >> 63
  5. return (x ^ y) - y
  6. }
  7. // Max returns the highest of the two given ints.
  8. func Max(x, y int) int {
  9. if x >= y {
  10. return x
  11. }
  12. return y
  13. }
  14. // Min returns the lowest of the two given ints.
  15. func Min(x, y int) int {
  16. if x <= y {
  17. return x
  18. }
  19. return y
  20. }