Multiply64BitInt Checking if the integer multiplication overflows
(left, right int64)
| 51 | |
| 52 | // Multiply64BitInt Checking if the integer multiplication overflows |
| 53 | func Multiply64BitInt(left, right int64) (int64, error) { |
| 54 | if math.Abs(float64(left)) > float64(math.MaxInt64)/math.Abs(float64(right)) { |
| 55 | return 0, ErrorIntOverflow |
| 56 | } |
| 57 | return left * right, nil |
| 58 | } |