utility.go 395 B

123456789101112131415161718192021222324252627282930
  1. package utility
  2. func Min(a, b int64) int64 {
  3. if a < b {
  4. return a
  5. }
  6. return b
  7. }
  8. func Max(a, b int64) int64 {
  9. if a > b {
  10. return a
  11. }
  12. return b
  13. }
  14. func Sequential(now, old float64) float64 {
  15. if old == 0 {
  16. return old
  17. }
  18. return (now - old) / old
  19. }
  20. // 计算公式
  21. func Formula(current, total float64) (result float64) {
  22. if total == 0 {
  23. return 0
  24. }
  25. result = current / total
  26. return
  27. }