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

Function LshiftInt64

math/checked/checked.go:76–84  ·  view source on GitHub ↗

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

(a, b int64)

Source from the content-addressed store, hash-verified

74// LshiftInt64 returns a << b
75// with an integer overflow check.
76func LshiftInt64(a, b int64) (result int64, ok bool) {
77 if b < 0 || b >= 64 {
78 return 0, false
79 }
80 if (a >= 0 && a > math.MaxInt64>>uint(b)) || (a < 0 && a < math.MinInt64>>uint(b)) {
81 return 0, false
82 }
83 return a << uint(b), true
84}
85
86// RshiftInt64 returns a >> b
87// with an integer overflow check.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected