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

Method AsInt64

postgres/parser/utils/bitarray.go:206–220  ·  view source on GitHub ↗

AsInt64 returns the int constituted from the rightmost bits in the bit array.

(nbits uint)

Source from the content-addressed store, hash-verified

204// AsInt64 returns the int constituted from the rightmost bits in the
205// bit array.
206func (d BitArray) AsInt64(nbits uint) int64 {
207 if d.lastBitsUsed == 0 {
208 // Fast path.
209 return 0
210 }
211
212 lowPart := d.words[len(d.words)-1] >> (numBitsPerWord - d.lastBitsUsed)
213 highPart := word(0)
214 if nbits > uint(d.lastBitsUsed) && len(d.words) > 1 {
215 highPart = d.words[len(d.words)-2] << d.lastBitsUsed
216 }
217 combined := lowPart | highPart
218 signExtended := int64(combined<<(numBitsPerWord-nbits)) >> (numBitsPerWord - nbits)
219 return signExtended
220}
221
222// LeftShiftAny performs a logical left shift, with a possible
223// negative count.

Callers 4

generate_series.goFile · 0.45
intervalPlusNonIntervalFunction · 0.45
minus.goFile · 0.45
bitExplicitFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected