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

Function SubWithOverflow

postgres/parser/utils/arith.go:61–69  ·  view source on GitHub ↗

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

(a, b int64)

Source from the content-addressed store, hash-verified

59
60// SubWithOverflow returns a-b. If ok is false, a-b overflowed.
61func SubWithOverflow(a, b int64) (r int64, ok bool) {
62 if b < 0 && a > math.MaxInt64+b {
63 return 0, false
64 }
65 if b > 0 && a < math.MinInt64+b {
66 return 0, false
67 }
68 return a - b, true
69}
70
71// Sub32to64WithOverflow returns a-b. If ok is false, b was outside the
72// int32 range or a-b overflowed.

Callers 2

MakeDateFromUnixEpochFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected