本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
615B

  1. // Copyright 2009 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package unix
  6. func itoa(val int) string { // do it here rather than with fmt to avoid dependency
  7. if val < 0 {
  8. return "-" + uitoa(uint(-val))
  9. }
  10. return uitoa(uint(val))
  11. }
  12. func uitoa(val uint) string {
  13. var buf [32]byte // big enough for int64
  14. i := len(buf) - 1
  15. for val >= 10 {
  16. buf[i] = byte(val%10 + '0')
  17. i--
  18. val /= 10
  19. }
  20. buf[i] = byte(val + '0')
  21. return string(buf[i:])
  22. }
上海开阖软件有限公司 沪ICP备12045867号-1