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

Function NewDBitArrayFromInt

postgres/parser/sem/tree/datum.go:308–315  ·  view source on GitHub ↗

NewDBitArrayFromInt creates a bit array from the specified integer at the specified width. If the width is zero, only positive integers can be converted. If the width is nonzero, the value is truncated to that width. Negative values are encoded using two's complement.

(i int64, width uint)

Source from the content-addressed store, hash-verified

306// If the width is nonzero, the value is truncated to that width.
307// Negative values are encoded using two's complement.
308func NewDBitArrayFromInt(i int64, width uint) (*DBitArray, error) {
309 if width == 0 && i < 0 {
310 return nil, errCannotCastNegativeIntToBitArray
311 }
312 return &DBitArray{
313 BitArray: utils.MakeBitArrayFromInt64(width, i, 64),
314 }, nil
315}
316
317// AsDInt computes the integer value of the given bit array.
318// The value is assumed to be encoded using two's complement.

Callers 1

SampleDatumFunction · 0.85

Calls 1

MakeBitArrayFromInt64Function · 0.92

Tested by

no test coverage detected