MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Multiply64BitInt

Function Multiply64BitInt

math/modular/exponentiation.go:53–58  ·  view source on GitHub ↗

Multiply64BitInt Checking if the integer multiplication overflows

(left, right int64)

Source from the content-addressed store, hash-verified

51
52// Multiply64BitInt Checking if the integer multiplication overflows
53func 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}

Callers 1

ExponentiationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected