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

Function LshiftInt32

math/checked/checked.go:156–164  ·  view source on GitHub ↗

LshiftInt32 returns a << b with an integer overflow check.

(a, b int32)

Source from the content-addressed store, hash-verified

154// LshiftInt32 returns a << b
155// with an integer overflow check.
156func LshiftInt32(a, b int32) (result int32, ok bool) {
157 if b < 0 || b >= 32 {
158 return 0, false
159 }
160 if (a >= 0 && a > math.MaxInt32>>uint(b)) || (a < 0 && a < math.MinInt32>>uint(b)) {
161 return 0, false
162 }
163 return a << uint(b), true
164}
165
166// AddUint64 returns a + b
167// with an integer overflow check.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected