MCPcopy Create free account
hub / github.com/chain/txvm / MulInt32

Function MulInt32

math/checked/checked.go:117–125  ·  view source on GitHub ↗

MulInt32 returns a * b with an integer overflow check.

(a, b int32)

Source from the content-addressed store, hash-verified

115// MulInt32 returns a * b
116// with an integer overflow check.
117func 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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected