round.go 329 B

12345678910
  1. package billingexpr
  2. import "math"
  3. // QuotaRound converts a float64 quota value to int using half-away-from-zero
  4. // rounding. Every tiered billing path (pre-consume, settlement, breakdown
  5. // validation, log fields) MUST use this function to avoid +-1 discrepancies.
  6. func QuotaRound(f float64) int {
  7. return int(math.Round(f))
  8. }