AddInt64 returns a + b with an integer overflow check.
(a, b int64)
| 15 | // AddInt64 returns a + b |
| 16 | // with an integer overflow check. |
| 17 | func AddInt64(a, b int64) (sum int64, ok bool) { |
| 18 | if (b > 0 && a > math.MaxInt64-b) || |
| 19 | (b < 0 && a < math.MinInt64-b) { |
| 20 | return 0, false |
| 21 | } |
| 22 | return a + b, true |
| 23 | } |
| 24 | |
| 25 | // SubInt64 returns a - b |
| 26 | // with an integer overflow check. |
no outgoing calls
no test coverage detected