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

Function UpperBoundNonsortingDecimalSize

postgres/parser/encoding/decimal.go:724–730  ·  view source on GitHub ↗

UpperBoundNonsortingDecimalSize returns the upper bound number of bytes that the decimal will need for the non-sorting encoding.

(d *apd.Decimal)

Source from the content-addressed store, hash-verified

722// UpperBoundNonsortingDecimalSize returns the upper bound number of bytes
723// that the decimal will need for the non-sorting encoding.
724func UpperBoundNonsortingDecimalSize(d *apd.Decimal) int {
725 // Makeup of upper bound size:
726 // - 1 byte for the prefix
727 // - MaxVarintLen for the exponent
728 // - WordLen for the big.Int bytes
729 return 1 + MaxVarintLen + WordLen(d.Coeff.Bits())
730}
731
732// Taken from math/big/arith.go.
733const bigWordSize = int(unsafe.Sizeof(big.Word(0)))

Callers 1

EncodeNonsortingDecimalFunction · 0.85

Calls 1

WordLenFunction · 0.85

Tested by

no test coverage detected