// NewQuantity returns a new Quantity representing the given
// value in the given format.
769524
func NewQuantity(value int64, format Format) *Quantity {
	return &Quantity{
		Amount: inf.NewDec(value, 0),
		Format: format,
	}
}
58825
func (s *CustomHeaders) SetQuantity(v int64) *CustomHeaders {
	s.Quantity = &v
	return s
}
977993
func (styles *xlsxStyleSheet) newNumFmt(formatCode string) xlsxNumFmt {
	if compareFormatString(formatCode, "general") {
		return xlsxNumFmt{NumFmtId: 0, FormatCode: "general"}
	}
	// built in NumFmts in xmlStyle.go, traverse from the const.
	numFmtId, ok := builtInNumFmtInv[formatCode]
	if ok {
		return xlsxNumFmt{NumFmtId: numFmtId, FormatCode: formatCode}
	}

	// find the exist xlsxNumFmt
	for _, numFmt := range styles.NumFmts.NumFmt {
		if formatCode == numFmt.FormatCode {
			return numFmt
		}
	}

	// The user define NumFmtId. The one less than 164 in built in.
	numFmtId = builtinNumFmtsCount + 1
	styles.Lock()
	defer styles.Unlock()
	for {
		// get a unused NumFmtId
		if _, ok = styles.numFmtRefTable[numFmtId]; ok {
			numFmtId++
		} else {
			styles.addNumFmt(xlsxNumFmt{NumFmtId: numFmtId, FormatCode: formatCode})
			break
		}
	}
	return xlsxNumFmt{NumFmtId: numFmtId, FormatCode: formatCode}
}
1036861
func (q *Quantity) Copy() *Quantity {
	if q.d.Dec == nil {
		return &Quantity{
			s:      q.s,
			i:      q.i,
			Format: q.Format,
		}
	}
	tmp := &inf.Dec{}
	return &Quantity{
		s:      q.s,
		d:      infDecAmount{tmp.Set(q.d.Dec)},
		Format: q.Format,
	}
}
840977
func (s *KeyPairIds) SetQuantity(v int64) *KeyPairIds {
	s.Quantity = &v
	return s
}
940633
func (h *Histogram) ValueAtQuantile(q float64) int64 {
	if q > 100 {
		q = 100
	}

	total := int64(0)
	countAtPercentile := int64(((q / 100) * float64(h.totalCount)) + 0.5)

	i := h.iterator()
	for i.next() {
		total += i.countAtIdx
		if total >= countAtPercentile {
			return h.highestEquivalentValue(i.valueFromIdx)
		}
	}

	return 0
}
196005
func (qs *QuadStore) WriteQuad(q quad.Quad) error {
	qs.AddQuad(q)
	return nil
}
419332
func newQuantizedFloatDecoder(bitCount, flags *int32, lowValue, highValue *float32) *quantizedFloatDecoder {
	qfd := &quantizedFloatDecoder{}

	// Set common properties
	if *bitCount == 0 || *bitCount >= 32 {
		qfd.NoScale = true
		qfd.Bitcount = 32
		return qfd
	} else {
		qfd.NoScale = false
		qfd.Bitcount = uint32(*bitCount)
		qfd.Offset = 0.0

		if lowValue != nil {
			qfd.Low = *lowValue
		} else {
			qfd.Low = 0.0
		}

		if highValue != nil {
			qfd.High = *highValue
		} else {
			qfd.High = 1.0
		}
	}
	if flags != nil {
		qfd.Flags = uint32(*flags)
	} else {
		qfd.Flags = 0
	}

	// Validate flags
	qfd.validateFlags()

	// Handle Round Up, Round Down
	steps := (1 << uint(qfd.Bitcount))

	Range := float32(0)
	if (qfd.Flags & qff_rounddown) != 0 {
		Range = qfd.High - qfd.Low
		qfd.Offset = (Range / float32(steps))
		qfd.High -= qfd.Offset
	} else if (qfd.Flags & qff_roundup) != 0 {
		Range = qfd.High - qfd.Low
		qfd.Offset = (Range / float32(steps))
		qfd.Low += qfd.Offset
	}

	// Handle integer encoding flag
	if (qfd.Flags & qff_encode_integers) != 0 {
		delta := qfd.High - qfd.Low

		if delta < 1 {
			delta = 1
		}

		deltaLog2 := math.Ceil(math.Log2(float64(delta)))
		Range2 := (1 << uint(deltaLog2))
		bc := qfd.Bitcount

		for 1 == 1 {
			if (1 << uint(bc)) > Range2 {
				break
			} else {
				bc++
			}
		}

		if bc > qfd.Bitcount {
			qfd.Bitcount = bc
			steps = (1 << uint(qfd.Bitcount))
		}

		qfd.Offset = float32(Range2) / float32(steps)
		qfd.High = qfd.Low + float32(Range2) - qfd.Offset
	}

	// Assign multipliers
	qfd.assignMultipliers(uint32(steps))

	// Remove unessecary flags
	if (qfd.Flags & qff_rounddown) != 0 {
		if qfd.quantize(qfd.Low) == qfd.Low {
			qfd.Flags &= ^qff_rounddown
		}
	}

	if (qfd.Flags & qff_roundup) != 0 {
		if qfd.quantize(qfd.High) == qfd.High {
			qfd.Flags &= ^qff_roundup
		}
	}

	if (qfd.Flags & qff_encode_zero) != 0 {
		if qfd.quantize(0.0) == 0.0 {
			qfd.Flags &= ^qff_encode_zero
		}
	}

	return qfd
}
91176
func (qs *QuadStore) AddQuad(q quad.Quad) (int64, bool) {
	p, _ := qs.resolveQuad(q, true)
	if id := qs.quads[p]; id != 0 {
		return id, false
	}
	pr := &primitive{Quad: p}
	id := qs.addPrimitive(pr)
	qs.quads[p] = id
	for _, t := range qs.indexesForQuad(p) {
		t.Set(id, pr)
	}
	// TODO(barakmich): Add VIP indexing
	return id, true
}
641915
func validateResourceQuantityValue(resource string, value resource.Quantity, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	allErrs = append(allErrs, ValidateNonnegativeQuantity(value, fldPath)...)
	if api.IsIntegerResourceName(resource) {
		if value.MilliValue()%int64(1000) != int64(0) {
			allErrs = append(allErrs, field.Invalid(fldPath, value, isNotIntegerErrorMsg))
		}
	}
	return allErrs
}
808893
func (q *Quantity) Value() int64 {
	if q.Amount == nil {
		return 0
	}
	return scaledValue(q.Amount.UnscaledBig(), int(q.Amount.Scale()), 0)
}
648703
func (q *Quantity) Value() int64 {
	if q.Amount == nil {
		return 0
	}
	tmp := &inf.Dec{}
	return tmp.Round(q.Amount, 0, inf.RoundUp).UnscaledBig().Int64()
}
368164
func (q *Quantity) QuantityProto() *QuantityProto {
	if q == nil {
		return &QuantityProto{}
	}
	p := &QuantityProto{
		Format: q.Format,
	}
	if q.Amount != nil {
		p.Scale = int32(q.Amount.Scale())
		p.Bigint = q.Amount.UnscaledBig().Bytes()
	}
	return p
}
33917
func (h *Client) ProductQuantity(productQuantity int64) *Client {
	h.productQuantity = productQuantity
	h.productQuantitySet = true
	return h
}
1227894
func (s *TrustedSigners) SetQuantity(v int64) *TrustedSigners {
	s.Quantity = &v
	return s
}
822135
func ValidatePositiveQuantity(value resource.Quantity, fldPath *validation.FieldPath) validation.ErrorList {
	allErrs := validation.ErrorList{}
	if value.Cmp(resource.Quantity{}) < 0 {
		allErrs = append(allErrs, validation.NewInvalidError(fldPath, value.String(), isNegativeErrorMsg))
	}
	return allErrs
}
345629
func NewIdentityFromLabelArray(id NumericIdentity, lblArray labels.LabelArray) *Identity {
	var lbls labels.Labels

	if lblArray != nil {
		lbls = lblArray.Labels()
	}
	return &Identity{ID: id, Labels: lbls, LabelArray: lblArray}
}