int.go 371 B

12345678910111213141516171819
  1. package tools
  2. import (
  3. "math"
  4. "strconv"
  5. )
  6. func IntToString(e int) string {
  7. return strconv.Itoa(e)
  8. }
  9. func Int64ToString(e int64) string {
  10. return strconv.FormatInt(e, 10)
  11. }
  12. func Round(f float64, n int) float64 {
  13. pow10_n := math.Pow10(n)
  14. return math.Trunc((f+0.5/pow10_n)*pow10_n) / pow10_n // TODO +0.5 是为了四舍五入,如果不希望这样去掉这个
  15. }