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

Function AddInt32

math/checked/checked.go:97–103  ·  view source on GitHub ↗

AddInt32 returns a + b with an integer overflow check.

(a, b int32)

Source from the content-addressed store, hash-verified

95// AddInt32 returns a + b
96// with an integer overflow check.
97func AddInt32(a, b int32) (sum int32, ok bool) {
98 if (b > 0 && a > math.MaxInt32-b) ||
99 (b < 0 && a < math.MinInt32-b) {
100 return 0, false
101 }
102 return a + b, true
103}
104
105// SubInt32 returns a - b
106// with an integer overflow check.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected