MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Sub32WithOverflow

Function Sub32WithOverflow

postgres/parser/utils/arith.go:81–89  ·  view source on GitHub ↗

Sub32WithOverflow returns a-b. If ok is false, a-b overflowed.

(a, b int32)

Source from the content-addressed store, hash-verified

79
80// Sub32WithOverflow returns a-b. If ok is false, a-b overflowed.
81func Sub32WithOverflow(a, b int32) (r int32, ok bool) {
82 if b < 0 && a > math.MaxInt32+b {
83 return 0, false
84 }
85 if b > 0 && a < math.MinInt32+b {
86 return 0, false
87 }
88 return a - b, true
89}
90
91// MulHalfPositiveWithOverflow returns a*b. b must be positive. If ok
92// is false, a*b overflowed.

Callers 1

Sub32to64WithOverflowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected