LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package strconv | 5 package strconv |
6 | 6 |
7 // Uitob64 returns the string representation of i in the given base. | 7 // Uitob64 returns the string representation of i in the given base. |
8 func Uitob64(u uint64, base uint) string { | 8 func Uitob64(u uint64, base uint) string { |
9 if base < 2 || 36 < base { | 9 if base < 2 || 36 < base { |
10 » » panic("invalid base" + Uitoa(base)) | 10 » » panic("invalid base " + Uitoa(base)) |
11 } | 11 } |
12 if u == 0 { | 12 if u == 0 { |
13 return "0" | 13 return "0" |
14 } | 14 } |
15 | 15 |
16 // Assemble decimal in reverse order. | 16 // Assemble decimal in reverse order. |
17 var buf [64]byte | 17 var buf [64]byte |
18 j := len(buf) | 18 j := len(buf) |
19 b := uint64(base) | 19 b := uint64(base) |
20 for u > 0 { | 20 for u > 0 { |
(...skipping 27 matching lines...) Expand all Loading... |
48 func Uitob(i uint, base uint) string { return Uitob64(uint64(i), base) } | 48 func Uitob(i uint, base uint) string { return Uitob64(uint64(i), base) } |
49 | 49 |
50 // Itob returns the string representation of i in the given base. | 50 // Itob returns the string representation of i in the given base. |
51 func Itob(i int, base uint) string { return Itob64(int64(i), base) } | 51 func Itob(i int, base uint) string { return Itob64(int64(i), base) } |
52 | 52 |
53 // Itoa returns the decimal string representation of i. | 53 // Itoa returns the decimal string representation of i. |
54 func Itoa(i int) string { return Itob64(int64(i), 10) } | 54 func Itoa(i int) string { return Itob64(int64(i), 10) } |
55 | 55 |
56 // Uitoa returns the decimal string representation of i. | 56 // Uitoa returns the decimal string representation of i. |
57 func Uitoa(i uint) string { return Uitob64(uint64(i), 10) } | 57 func Uitoa(i uint) string { return Uitob64(uint64(i), 10) } |
LEFT | RIGHT |