// FormatPercent takes a float number and returns a properly formatted string
// representation of that number as a percentage according to the locale's
// percentage format.
518526
func (n Number) FmtPercent(number float64) string {
	return n.formatNumber(n.parseFormat(n.Formats.Percent, true), number)
}
1255862
func (s *UpgradeStepItem) SetProgressPercent(v float64) *UpgradeStepItem {
	s.ProgressPercent = &v
	return s
}
833056
func (s *DBSnapshot) SetPercentProgress(v int64) *DBSnapshot {
	s.PercentProgress = &v
	return s
}
888244
func (p *PercentilesBucketAggregation) Format(format string) *PercentilesBucketAggregation {
	p.format = format
	return p
}
361852
func formatToInt(i int, v string) string {
	f, err := strconv.ParseFloat(v, 64)
	if err != nil {
		return v
	}
	return fmt.Sprintf("%d", int(f))
}
140593
func (l *Logger) Percentage(msg string, total uint64) *PercentageTask {
	t := NewPercentageTask(msg, total)
	l.Enqueue(t)

	return t
}
1284156
func Percent(p int) bool {
	if p >= 100 {
		return true
	}

	if p <= 0 {
		return false
	}

	return getRandNumber() > (100 - p)
}
460484
func FormatNumberFloat64(x float64, precision int, thousand string, decimalStr string) string {
	return formatNumberString(fmt.Sprintf(fmt.Sprintf("%%.%df", precision), x), precision, thousand, decimalStr)
}
823546
func (b *Box) FillWithPercentageMargins(container *Box, horizmarginp float32, vertmarginp float32) {
	horizmargin := int(float32(container.inner.W) * horizmarginp)
	vertmargin := int(float32(container.inner.H) * vertmarginp)
	b.Fill(container)
	b.frame.X += horizmargin
	b.frame.Y += vertmargin
	b.frame.W -= horizmargin * 2
	b.frame.H -= vertmargin * 2
}
247228
func (s *ApprovalThresholdPolicy) SetThresholdPercentage(v int64) *ApprovalThresholdPolicy {
	s.ThresholdPercentage = &v
	return s
}
283970
func PercentValue(value, sum float64) (s string) {
	value *= 100 / sum
	s = AbsoluteValue(value, sum) + "% "
	return
}
90207
func Format(value interface{}) string {
	if value == nil {
		return "nil"
	}

	t := reflect.TypeOf(value)
	formatter := formatters[t.Kind().String()]
	if formatter == nil {
		formatter = formatters[t.String()]
	}

	if formatter == nil {
		if _, ok := t.MethodByName("Error"); ok == true {
			return formatString(value.(error).Error())
		} else {
			return formatString(fmt.Sprintf("%+v", value))
		}
	}

	return formatter(value)
}
308801
func (p *ProgressBar) percentage() float64 {
	pct := float64(p.Current) / float64(p.Total)
	if p.Total == 0 {
		if p.Current == 0 {
			// When both Total and Current are 0, show a full progressbar
			pct = 1
		} else {
			pct = 0
		}
	}

	// percentage is bound between 0 and 1
	return math.Min(1, math.Max(0, pct))
}
1219919
func (s *CampaignResponse) SetHoldoutPercent(v int64) *CampaignResponse {
	s.HoldoutPercent = &v
	return s
}
42543
func (t *Translator) formatNumber(format *numberFormat, number float64) string {
	negative := number < 0

	// apply the multiplier first - this is mainly used for percents
	value := math.Abs(number * float64(format.multiplier))
	stringValue := ""

	// get the initial string value, with the maximum # decimal digits
	if format.maxDecimalDigits >= 0 {
		stringValue = numberRound(value, format.maxDecimalDigits)
	} else {
		stringValue = fmt.Sprintf("%f", value)
	}

	// separate the integer from the decimal parts
	pos := strings.Index(stringValue, ".")
	integer := stringValue
	decimal := ""
	if pos != -1 {
		integer = stringValue[:pos]
		decimal = stringValue[pos+1:]
	}

	// make sure the minimum # decimal digits are there
	for len(decimal) < format.minDecimalDigits {
		decimal = decimal + "0"
	}

	// make sure the minimum # integer digits are there
	for len(integer) < format.minIntegerDigits {
		integer = "0" + integer
	}

	// if there's a decimal portion, prepend the decimal point symbol
	if len(decimal) > 0 {
		decimal = string(t.rules.Numbers.Symbols.Decimal) + decimal
	}

	// put the integer portion into properly sized groups
	if format.groupSizeFinal > 0 && len(integer) > format.groupSizeFinal {
		if len(integer) > format.groupSizeMain {
			groupFinal := integer[len(integer)-format.groupSizeFinal:]
			groupFirst := integer[:len(integer)-format.groupSizeFinal]
			integer = strings.Join(chunkString(groupFirst, format.groupSizeMain), t.rules.Numbers.Symbols.Group) + t.rules.Numbers.Symbols.Group + groupFinal
		}
	}

	// append/prepend negative/positive prefix/suffix
	formatted := ""
	if negative {
		formatted = format.negativePrefix + integer + decimal + format.negativeSuffix
	} else {
		formatted = format.positivePrefix + integer + decimal + format.positiveSuffix
	}

	// replace percents and permilles with the local symbols (likely to be exactly the same)
	formatted = strings.Replace(formatted, "%", string(t.rules.Numbers.Symbols.Percent), -1)
	formatted = strings.Replace(formatted, "‰", string(t.rules.Numbers.Symbols.Permille), -1)

	return formatted
}
880948
func (s *LogGroupField) SetPercent(v int64) *LogGroupField {
	s.Percent = &v
	return s
}
1090650
func (s *SlotMigration) SetProgressPercentage(v float64) *SlotMigration {
	s.ProgressPercentage = &v
	return s
}