// NewMilliQuantity returns a new Quantity representing the given
// value * 1/1000 in the given format. Note that BinarySI formatting
// will round fractional values, and will be changed to DecimalSI for
// values x where (-1 < x < 1) && (x != 0).
484112
func NewMilliQuantity(value int64, format Format) *Quantity {
	return &Quantity{
		i:      int64Amount{value: value, scale: -3},
		Format: format,
	}
}
67466
func (q *Quantity) Copy() *Quantity {
	if q.Amount == nil {
		return NewQuantity(0, q.Format)
	}
	tmp := &inf.Dec{}
	return &Quantity{
		Amount: tmp.Set(q.Amount),
		Format: q.Format,
	}
}
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
}
1235886
func calcMemSize64(off, l *big.Int) (uint64, bool) {
	if !l.IsUint64() {
		return 0, true
	}
	return calcMemSize64WithUint(off, l.Uint64())
}
385197
func (s *StreamingDistributionList) SetQuantity(v int64) *StreamingDistributionList {
	s.Quantity = &v
	return s
}
58825
func (s *CustomHeaders) SetQuantity(v int64) *CustomHeaders {
	s.Quantity = &v
	return s
}
437622
func StellarSimplifyAmount(amount string) string {
	sides := strings.Split(amount, ".")
	if len(sides) != 2 {
		return amount
	}
	simpleRight := strings.TrimRight(sides[1], "0")
	if strings.Contains(sides[0], ",") {
		// If integer part has the thousands separator (comma), always
		// print the fractional part with at least two digits - this
		// is to ensure that thousands separator is not confused with
		// decimal point.
		for len(simpleRight) < 2 {
			simpleRight = simpleRight + "0"
		}
	} else if len(simpleRight) == 0 {
		return sides[0]
	}
	return sides[0] + "." + simpleRight
}
678539
func crcAccumulate(data uint8, crcAccum uint16) uint16 {
	/*Accumulate one byte of data into the CRC*/
	var tmp uint8

	tmp = data ^ (uint8)(crcAccum&0xff)
	tmp ^= (tmp << 4)
	crcAccum = (uint16(crcAccum) >> 8) ^ (uint16(tmp) << 8) ^ (uint16(tmp) << 3) ^ (uint16(tmp) >> 4)
	return crcAccum
}
1015447
func NewScaledQuantity(value int64, scale Scale) *Quantity {
	return &Quantity{
		Amount: inf.NewDec(value, scale.infScale()),
		Format: DecimalSI,
	}
}
970925
func (accounting *Accounting) FormatMoneyBigFloat(value *big.Float) string {
	accounting.init()
	formattedNumber := FormatNumberBigFloat(value, accounting.Precision, accounting.Thousand, accounting.Decimal)
	return accounting.formatMoneyString(formattedNumber)
}
79755
func FormatNumberDecimal(x decimal.Decimal, precision int, thousand string, decimalStr string) string {
	return formatNumberString(x.StringFixed(int32(precision)), precision, thousand, decimalStr)
}
1204600
func NewAccounting(symbol string, precision int, thousand, decimal, format, formatNegative, formatZero string) *Accounting {
	ac := &Accounting{
		Symbol: symbol,
		Precision: precision,
		Thousand: thousand,
		Decimal: decimal,
		Format: format,
		FormatNegative: formatNegative,
		FormatZero: formatZero,
	}
	ac.isInitialized = true
	return ac
}
1233136
func FormatNumberBigDecimal(x *apd.Decimal, precision int, thousand string, decimalStr string) string {
	d := apd.New(0, 0)
	apd.BaseContext.WithPrecision(uint32(x.NumDigits()) + uint32(precision)).Quantize(d, x, int32(-precision))
	return formatNumberString(d.Text('f'), precision, thousand, decimalStr)
}
994281
func (s *Origins) SetQuantity(v int64) *Origins {
	s.Quantity = &v
	return s
}
628089
func (s *FieldPatterns) SetQuantity(v int64) *FieldPatterns {
	s.Quantity = &v
	return s
}
556743
func (s *OriginGroups) SetQuantity(v int64) *OriginGroups {
	s.Quantity = &v
	return s
}
561258
func (s *OriginAccessIdentityList) SetQuantity(v int64) *OriginAccessIdentityList {
	s.Quantity = &v
	return s
}