MulInt32 returns a * b with an integer overflow check.
(a, b int32)
| 115 | // MulInt32 returns a * b |
| 116 | // with an integer overflow check. |
| 117 | func MulInt32(a, b int32) (product int32, ok bool) { |
| 118 | if (a > 0 && b > 0 && a > math.MaxInt32/b) || |
| 119 | (a > 0 && b <= 0 && b < math.MinInt32/a) || |
| 120 | (a <= 0 && b > 0 && a < math.MinInt32/b) || |
| 121 | (a < 0 && b <= 0 && b < math.MaxInt32/a) { |
| 122 | return 0, false |
| 123 | } |
| 124 | return a * b, true |
| 125 | } |
| 126 | |
| 127 | // DivInt32 returns a / b |
| 128 | // with an integer overflow check. |
nothing calls this directly
no outgoing calls
no test coverage detected