charge.go 353 B

1234567891011
  1. package coin
  2. import "github.com/shopspring/decimal"
  3. // 根据输入的base金额的charge比例数量,向上取整
  4. func CoinByCharge(coinNumber Coin, charge float64) int64 {
  5. return decimal.NewFromInt(int64(coinNumber)).Mul(decimal.NewFromFloat(charge)).Add(decimal.NewFromFloat(0.5)).IntPart()
  6. //return int64(float64(coinNumber)*charge + 0.5)
  7. }