MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / NewDBitArrayFromInt

Function NewDBitArrayFromInt

pkg/sql/sem/tree/datum.go:507–514  ·  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

505// If the width is nonzero, the value is truncated to that width.
506// Negative values are encoded using two's complement.
507func NewDBitArrayFromInt(i int64, width uint) (*DBitArray, error) {
508 if width == 0 && i < 0 {
509 return nil, errCannotCastNegativeIntToBitArray
510 }
511 return &DBitArray{
512 BitArray: bitarray.MakeBitArrayFromInt64(width, i, 64),
513 }, nil
514}
515
516// AsDInt computes the integer value of the given bit array.
517// The value is assumed to be encoded using two's complement.

Callers 2

PerformCastFunction · 0.85
SampleDatumFunction · 0.85

Calls 1

MakeBitArrayFromInt64Function · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…