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

Function NewDBitArrayFromInt

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

560// If the width is nonzero, the value is truncated to that width.
561// Negative values are encoded using two's complement.
562func NewDBitArrayFromInt(i int64, width uint) (*DBitArray, error) {
563 if width == 0 && i < 0 {
564 return nil, errCannotCastNegativeIntToBitArray
565 }
566 return &DBitArray{
567 BitArray: bitarray.MakeBitArrayFromInt64(width, i, 64),
568 }, nil
569}
570
571// AsDInt computes the integer value of the given bit array.
572// 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…