}
}
-
// Custom grammar and values
var precTab = map[string]int{
if err == nil {
return Int(x)
}
- b, err := strconv.Atob(lit)
+ b, err := strconv.ParseBool(lit)
if err == nil {
return Bool(b)
}
type Bool bool
-func (x Bool) String() string { return strconv.Btoa(bool(x)) }
+func (x Bool) String() string { return strconv.FormatBool(bool(x)) }
func (x Bool) BinaryOp(op string, y Value) Value {
switch y := y.(type) {
case Error:
return Error(fmt.Sprintf("illegal operation: '%v %s %v'", x, op, y))
}
-
func trace(newVal func(string) Value) func(string) Value {
return func(s string) Value {
v := newVal(s)
}
}
-
// Custom grammar and values
var precTab = map[string]int{
if err == nil {
return Int(x)
}
- b, err := strconv.Atob(lit)
+ b, err := strconv.ParseBool(lit)
if err == nil {
return Bool(b)
}
type Bool bool
-func (x Bool) String() string { return strconv.Btoa(bool(x)) }
+func (x Bool) String() string { return strconv.FormatBool(bool(x)) }
func (x Bool) BinaryOp(op string, y Value) Value {
switch y := y.(type) {
case Error:
return Error(fmt.Sprintf("illegal operation: '%v %s %v'", x, op, y))
}
-
func trace(newVal func(string) Value) func(string) Value {
return func(s string) Value {
v := newVal(s)
}
for {
j := <-c
- stdio.Stdout.WriteString(strconv.Itoa64(j) + "\n")
+ stdio.Stdout.WriteString(strconv.FormatInt(j, 10) + "\n")
out <- j
<-out
i += j
"builder": b.name,
"key": b.key,
"path": pkg,
- "ok": strconv.Btoa(ok),
+ "ok": strconv.FormatBool(ok),
"log": buildLog,
"info": info,
})
// with enum-derived constants. Otherwise
// in the cgo -godefs output half the constants
// are in hex and half are in whatever the #define used.
- i, err := strconv.Btoi64(n.Define, 0)
+ i, err := strconv.ParseInt(n.Define, 0, 64)
if err == nil {
n.Const = fmt.Sprintf("%#x", i)
} else {
func (c *typeConv) intExpr(n int64) ast.Expr {
return &ast.BasicLit{
Kind: token.INT,
- Value: strconv.Itoa64(n),
+ Value: strconv.FormatInt(n, 10),
}
}
const rPrefix = "release.r"
if strings.HasPrefix(goVersion, rPrefix) {
p := "go.r"
- v, err := strconv.Atof64(goVersion[len(rPrefix):])
+ v, err := strconv.ParseFloat(goVersion[len(rPrefix):], 64)
if err != nil {
return ""
}
if !strings.HasPrefix(t, p) {
continue
}
- tf, err := strconv.Atof64(t[len(p):])
+ tf, err := strconv.ParseFloat(t[len(p):], 64)
if err != nil {
continue
}
// setBoolFlag sets the addressed boolean to the value.
func setBoolFlag(flag *bool, value string) {
- x, err := strconv.Atob(value)
+ x, err := strconv.ParseBool(value)
if err != nil {
fmt.Fprintf(os.Stderr, "gotest: illegal bool flag value %s\n", value)
usage()
for len(b) > 0 && (b[len(b)-1] == ' ' || b[len(b)-1] == '\x00') {
b = b[0 : len(b)-1]
}
- x, err := strconv.Btoui64(cString(b), 8)
+ x, err := strconv.ParseUint(cString(b), 8, 64)
if err != nil {
tr.err = err
}
// Encode x as an octal ASCII string and write it into b with leading zeros.
func (tw *Writer) octal(b []byte, x int64) {
- s := strconv.Itob64(x, 8)
+ s := strconv.FormatInt(x, 8)
// leading zeros, but leave room for a NUL.
for len(s)+1 < len(b) {
s = "0" + s
// Write x into b, either as octal or as binary (GNUtar/star extension).
func (tw *Writer) numeric(b []byte, x int64) {
// Try octal first.
- s := strconv.Itob64(x, 8)
+ s := strconv.FormatInt(x, 8)
if len(s) < len(b) {
tw.octal(b, x)
return
}
func (err WrongValueError) Error() string {
- return "huffmanBitWriter: " + err.name + " should belong to [" + strconv.Itoa64(int64(err.from)) + ";" +
- strconv.Itoa64(int64(err.to)) + "] but actual value is " + strconv.Itoa64(int64(err.value))
+ return "huffmanBitWriter: " + err.name + " should belong to [" + strconv.FormatInt(int64(err.from), 10) + ";" +
+ strconv.FormatInt(int64(err.to), 10) + "] but actual value is " + strconv.FormatInt(int64(err.value), 10)
}
func (w *huffmanBitWriter) flushBits() {
type CorruptInputError int64
func (e CorruptInputError) Error() string {
- return "flate: corrupt input before offset " + strconv.Itoa64(int64(e))
+ return "flate: corrupt input before offset " + strconv.FormatInt(int64(e), 10)
}
// An InternalError reports an error in the flate code itself.
}
func (e *ReadError) Error() string {
- return "flate: read error at offset " + strconv.Itoa64(e.Offset) + ": " + e.Err.Error()
+ return "flate: read error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error()
}
// A WriteError reports an error encountered while writing output.
}
func (e *WriteError) Error() string {
- return "flate: write error at offset " + strconv.Itoa64(e.Offset) + ": " + e.Err.Error()
+ return "flate: write error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error()
}
// Huffman decoder is based on
for i := range to {
encryptKeys[i] = to[i].encryptionKey()
if encryptKeys[i].PublicKey == nil {
- return nil, error_.InvalidArgumentError("cannot encrypt a message to key id " + strconv.Uitob64(to[i].PrimaryKey.KeyId, 16) + " because it has no encryption keys")
+ return nil, error_.InvalidArgumentError("cannot encrypt a message to key id " + strconv.FormatUint(to[i].PrimaryKey.KeyId, 16) + " because it has no encryption keys")
}
sig := to[i].primaryIdentity().SelfSignature
var serve = flag.Bool("serve", false, "run a TLS server on :10443")
var testCipherSuites = flag.String("ciphersuites",
- "0x"+strconv.Itob(int(TLS_RSA_WITH_RC4_128_SHA), 16),
+ "0x"+strconv.FormatInt(int64(TLS_RSA_WITH_RC4_128_SHA), 16),
"cipher suites to accept in serving mode")
func TestRunServer(t *testing.T) {
suites := strings.Split(*testCipherSuites, ",")
testConfig.CipherSuites = make([]uint16, len(suites))
for i := range suites {
- suite, err := strconv.Btoui64(suites[i], 0)
+ suite, err := strconv.ParseUint(suites[i], 0, 64)
if err != nil {
panic(err)
}
}
func (e DecodeError) Error() string {
- return "decoding dwarf section " + e.Name + " at offset 0x" + strconv.Itob64(int64(e.Offset), 16) + ": " + e.Err
+ return "decoding dwarf section " + e.Name + " at offset 0x" + strconv.FormatInt(int64(e.Offset), 16) + ": " + e.Err
}
return "dwarf.Attr" + s
}
}
- return "dwarf.Attr(" + strconv.Itoa64(int64(a)) + ")"
+ return "dwarf.Attr(" + strconv.FormatInt(int64(a), 10) + ")"
}
// A format is a DWARF data encoding format.
return "dwarf.Tag" + s
}
}
- return "dwarf.Tag(" + strconv.Itoa64(int64(t)) + ")"
+ return "dwarf.Tag(" + strconv.FormatInt(int64(t), 10) + ")"
}
// Location expression operators.
}
func (t *ArrayType) String() string {
- return "[" + strconv.Itoa64(t.Count) + "]" + t.Type.String()
+ return "[" + strconv.FormatInt(t.Count, 10) + "]" + t.Type.String()
}
func (t *ArrayType) Size() int64 { return t.Count * t.Type.Size() }
s += "; "
}
s += f.Name + " " + f.Type.String()
- s += "@" + strconv.Itoa64(f.ByteOffset)
+ s += "@" + strconv.FormatInt(f.ByteOffset, 10)
if f.BitSize > 0 {
- s += " : " + strconv.Itoa64(f.BitSize)
- s += "@" + strconv.Itoa64(f.BitOffset)
+ s += " : " + strconv.FormatInt(f.BitSize, 10)
+ s += "@" + strconv.FormatInt(f.BitOffset, 10)
}
}
s += "}"
if i > 0 {
s += "; "
}
- s += v.Name + "=" + strconv.Itoa64(v.Val)
+ s += v.Name + "=" + strconv.FormatInt(v.Val, 10)
}
s += "}"
return s
if goSyntax {
s = "elf." + s
}
- return s + "+" + strconv.Uitoa64(uint64(i-n.i))
+ return s + "+" + strconv.FormatUint(uint64(i-n.i), 10)
}
}
- return strconv.Uitoa64(uint64(i))
+ return strconv.FormatUint(uint64(i), 10)
}
func flagName(i uint32, names []intName, goSyntax bool) string {
}
}
if len(s) == 0 {
- return "0x" + strconv.Uitob64(uint64(i), 16)
+ return "0x" + strconv.FormatUint(uint64(i), 16)
}
if i != 0 {
- s += "+0x" + strconv.Uitob64(uint64(i), 16)
+ s += "+0x" + strconv.FormatUint(uint64(i), 16)
}
return s
}
return n.s
}
}
- return strconv.Uitoa64(uint64(i))
+ return strconv.FormatUint(uint64(i), 10)
}
func flagName(i uint32, names []intName, goSyntax bool) string {
}
}
if len(s) == 0 {
- return "0x" + strconv.Uitob64(uint64(i), 16)
+ return "0x" + strconv.FormatUint(uint64(i), 16)
}
if i != 0 {
- s += "+0x" + strconv.Uitob64(uint64(i), 16)
+ s += "+0x" + strconv.FormatUint(uint64(i), 16)
}
return s
}
type CorruptInputError int64
func (e CorruptInputError) Error() string {
- return "illegal ascii85 data at input byte " + strconv.Itoa64(int64(e))
+ return "illegal ascii85 data at input byte " + strconv.FormatInt(int64(e), 10)
}
// Decode decodes src into dst, returning both the number
case part == "printable":
ret.stringType = tagPrintableString
case strings.HasPrefix(part, "default:"):
- i, err := strconv.Atoi64(part[8:])
+ i, err := strconv.ParseInt(part[8:], 10, 64)
if err == nil {
ret.defaultValue = new(int64)
*ret.defaultValue = i
type CorruptInputError int64
func (e CorruptInputError) Error() string {
- return "illegal base32 data at input byte " + strconv.Itoa64(int64(e))
+ return "illegal base32 data at input byte " + strconv.FormatInt(int64(e), 10)
}
// decode is like Decode but returns an additional 'end' value, which
type CorruptInputError int64
func (e CorruptInputError) Error() string {
- return "illegal base64 data at input byte " + strconv.Itoa64(int64(e))
+ return "illegal base64 data at input byte " + strconv.FormatInt(int64(e), 10)
}
// decode is like Decode but returns an additional 'end' value, which
type CorruptInputError int64
func (e CorruptInputError) Error() string {
- return "illegal git85 data at input byte " + strconv.Itoa64(int64(e))
+ return "illegal git85 data at input byte " + strconv.FormatInt(int64(e), 10)
}
const encode = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"
default:
d.error(&UnmarshalTypeError{"number", v.Type()})
case reflect.Interface:
- n, err := strconv.Atof64(s)
+ n, err := strconv.ParseFloat(s, 64)
if err != nil {
d.saveError(&UnmarshalTypeError{"number " + s, v.Type()})
break
v.Set(reflect.ValueOf(n))
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- n, err := strconv.Atoi64(s)
+ n, err := strconv.ParseInt(s, 10, 64)
if err != nil || v.OverflowInt(n) {
d.saveError(&UnmarshalTypeError{"number " + s, v.Type()})
break
v.SetInt(n)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- n, err := strconv.Atoui64(s)
+ n, err := strconv.ParseUint(s, 10, 64)
if err != nil || v.OverflowUint(n) {
d.saveError(&UnmarshalTypeError{"number " + s, v.Type()})
break
v.SetUint(n)
case reflect.Float32, reflect.Float64:
- n, err := strconv.AtofN(s, v.Type().Bits())
+ n, err := strconv.ParseFloat(s, v.Type().Bits())
if err != nil || v.OverflowFloat(n) {
d.saveError(&UnmarshalTypeError{"number " + s, v.Type()})
break
if c != '-' && (c < '0' || c > '9') {
d.error(errPhase)
}
- n, err := strconv.Atof64(string(item))
+ n, err := strconv.ParseFloat(string(item), 64)
if err != nil {
d.saveError(&UnmarshalTypeError{"number " + string(item), reflect.TypeOf(0.0)})
}
if len(s) < 6 || s[0] != '\\' || s[1] != 'u' {
return -1
}
- r, err := strconv.Btoui64(string(s[2:6]), 16)
+ r, err := strconv.ParseUint(string(s[2:6]), 16, 64)
if err != nil {
return -1
}
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- writeString(e, strconv.Itoa64(v.Int()))
+ writeString(e, strconv.FormatInt(v.Int(), 10))
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- writeString(e, strconv.Uitoa64(v.Uint()))
+ writeString(e, strconv.FormatUint(v.Uint(), 10))
case reflect.Float32, reflect.Float64:
- writeString(e, strconv.FtoaN(v.Float(), 'g', -1, v.Type().Bits()))
+ writeString(e, strconv.FormatFloat(v.Float(), 'g', -1, v.Type().Bits()))
case reflect.String:
if quoted {
switch k := val.Kind(); k {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- p.WriteString(strconv.Itoa64(val.Int()))
+ p.WriteString(strconv.FormatInt(val.Int(), 10))
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- p.WriteString(strconv.Uitoa64(val.Uint()))
+ p.WriteString(strconv.FormatUint(val.Uint(), 10))
case reflect.Float32, reflect.Float64:
- p.WriteString(strconv.Ftoa64(val.Float(), 'g', -1))
+ p.WriteString(strconv.FormatFloat(val.Float(), 'g', -1, 64))
case reflect.String:
Escape(p, []byte(val.String()))
case reflect.Bool:
- p.WriteString(strconv.Btoa(val.Bool()))
+ p.WriteString(strconv.FormatBool(val.Bool()))
case reflect.Array:
// will be [...]byte
bytes := make([]byte, val.Len())
// Helper functions for integer and unsigned integer conversions
var itmp int64
getInt64 := func() bool {
- itmp, err = strconv.Atoi64(string(src))
+ itmp, err = strconv.ParseInt(string(src), 10, 64)
// TODO: should check sizes
return err == nil
}
var utmp uint64
getUint64 := func() bool {
- utmp, err = strconv.Atoui64(string(src))
+ utmp, err = strconv.ParseUint(string(src), 10, 64)
// TODO: check for overflow?
return err == nil
}
var ftmp float64
getFloat64 := func() bool {
- ftmp, err = strconv.Atof64(string(src))
+ ftmp, err = strconv.ParseFloat(string(src), 64)
// TODO: check for overflow?
return err == nil
}
}
t.SetFloat(ftmp)
case reflect.Bool:
- value, err := strconv.Atob(strings.TrimSpace(string(src)))
+ value, err := strconv.ParseBool(strings.TrimSpace(string(src)))
if err != nil {
return err
}
var n uint64
var err error
if i >= 3 && s[1] == 'x' {
- n, err = strconv.Btoui64(s[2:], 16)
+ n, err = strconv.ParseUint(s[2:], 16, 64)
} else {
- n, err = strconv.Btoui64(s[1:], 10)
+ n, err = strconv.ParseUint(s[1:], 10, 64)
}
if err == nil && n <= unicode.MaxRune {
text = string(n)
decomp = decomp[1:]
}
for _, d := range decomp {
- point, err := strconv.Btoui64(d, 16)
+ point, err := strconv.ParseUint(d, 16, 64)
if err != nil {
return a, err
}
if len(field) != NumField {
logger.Fatalf("%5s: %d fields (expected %d)\n", line, len(field), NumField)
}
- x, err := strconv.Btoui64(field[FCodePoint], 16)
+ x, err := strconv.ParseUint(field[FCodePoint], 16, 64)
point := int(x)
if err != nil {
logger.Fatalf("%.5s...: %s", line, err)
if state != SLast {
firstChar = lastChar
}
- x, err = strconv.Atoui64(field[FCanonicalCombiningClass])
+ x, err = strconv.ParseUint(field[FCanonicalCombiningClass], 10, 64)
if err != nil {
logger.Fatalf("%U: bad ccc field: %s", int(x), err)
}
if len(matches) != 2 {
logger.Fatalf("%s: %d matches (expected 1)\n", line, len(matches))
}
- point, err := strconv.Btoui64(matches[1], 16)
+ point, err := strconv.ParseUint(matches[1], 16, 64)
if err != nil {
logger.Fatalf("%.5s...: %s", line, err)
}
continue
}
rng := strings.Split(qc[1], "..")
- i, err := strconv.Btoui64(rng[0], 16)
+ i, err := strconv.ParseUint(rng[0], 16, 64)
if err != nil {
log.Fatal(err)
}
j := i
if len(rng) > 1 {
- j, err = strconv.Btoui64(rng[1], 16)
+ j, err = strconv.ParseUint(rng[1], 16, 64)
if err != nil {
log.Fatal(err)
}
counter++
for j := 1; j < len(m)-1; j++ {
for _, split := range strings.Split(m[j], " ") {
- r, err := strconv.Btoui64(split, 16)
+ r, err := strconv.ParseUint(split, 16, 64)
if err != nil {
logger.Fatal(err)
}
switch dv.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
s := asString(src)
- i64, err := strconv.Atoi64(s)
+ i64, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
}
return nil
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
s := asString(src)
- u64, err := strconv.Atoui64(s)
+ u64, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
}
return nil
case reflect.Float32, reflect.Float64:
s := asString(src)
- f64, err := strconv.Atof64(s)
+ f64, err := strconv.ParseFloat(s, 64)
if err != nil {
return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
}
case bool:
return s, nil
case string:
- b, err := strconv.Atob(s)
+ b, err := strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("sql/driver: couldn't convert %q into type bool", s)
}
return b, nil
case []byte:
- b, err := strconv.Atob(string(s))
+ b, err := strconv.ParseBool(string(s))
if err != nil {
return nil, fmt.Errorf("sql/driver: couldn't convert %q into type bool", s)
}
lit := p.expect(scanner.Int)
p.expect(']')
elt := p.parseType()
- n, err := strconv.Atoui64(lit)
+ n, err := strconv.ParseUint(lit, 10, 64)
if err != nil {
p.error(err)
}
// exponent (base 2)
p.next()
sign, val = p.parseInt()
- exp, err := strconv.Atoui(val)
+ exp64, err := strconv.ParseUint(val, 10, 0)
if err != nil {
p.error(err)
}
+ exp := uint(exp64)
if sign == "-" {
denom := big.NewInt(1)
denom.Lsh(denom, exp)
mu sync.Mutex
}
-func (v *Int) String() string { return strconv.Itoa64(v.i) }
+func (v *Int) String() string { return strconv.FormatInt(v.i, 10) }
func (v *Int) Add(delta int64) {
v.mu.Lock()
mu sync.Mutex
}
-func (v *Float) String() string { return strconv.Ftoa64(v.f, 'g', -1) }
+func (v *Float) String() string { return strconv.FormatFloat(v.f, 'g', -1, 64) }
// Add adds delta to v.
func (v *Float) Add(delta float64) {
}
func (b *boolValue) Set(s string) bool {
- v, err := strconv.Atob(s)
+ v, err := strconv.ParseBool(s)
*b = boolValue(v)
return err == nil
}
}
func (i *intValue) Set(s string) bool {
- v, err := strconv.Btoi64(s, 0)
+ v, err := strconv.ParseInt(s, 0, 64)
*i = intValue(v)
return err == nil
}
}
func (i *int64Value) Set(s string) bool {
- v, err := strconv.Btoi64(s, 0)
+ v, err := strconv.ParseInt(s, 0, 64)
*i = int64Value(v)
return err == nil
}
}
func (i *uintValue) Set(s string) bool {
- v, err := strconv.Btoui64(s, 0)
+ v, err := strconv.ParseUint(s, 0, 64)
*i = uintValue(v)
return err == nil
}
}
func (i *uint64Value) Set(s string) bool {
- v, err := strconv.Btoui64(s, 0)
+ v, err := strconv.ParseUint(s, 0, 64)
*i = uint64Value(v)
return err == nil
}
}
func (f *float64Value) Set(s string) bool {
- v, err := strconv.Atof64(s)
+ v, err := strconv.ParseFloat(s, 64)
*f = float64Value(v)
return err == nil
}
}
// fmt_e64 formats a float64 in the form -1.23e+12.
-func (f *fmt) fmt_e64(v float64) { f.plusSpace(strconv.Ftoa64(v, 'e', doPrec(f, 6))) }
+func (f *fmt) fmt_e64(v float64) { f.plusSpace(strconv.FormatFloat(v, 'e', doPrec(f, 6), 64)) }
// fmt_E64 formats a float64 in the form -1.23E+12.
-func (f *fmt) fmt_E64(v float64) { f.plusSpace(strconv.Ftoa64(v, 'E', doPrec(f, 6))) }
+func (f *fmt) fmt_E64(v float64) { f.plusSpace(strconv.FormatFloat(v, 'E', doPrec(f, 6), 64)) }
// fmt_f64 formats a float64 in the form -1.23.
-func (f *fmt) fmt_f64(v float64) { f.plusSpace(strconv.Ftoa64(v, 'f', doPrec(f, 6))) }
+func (f *fmt) fmt_f64(v float64) { f.plusSpace(strconv.FormatFloat(v, 'f', doPrec(f, 6), 64)) }
// fmt_g64 formats a float64 in the 'f' or 'e' form according to size.
-func (f *fmt) fmt_g64(v float64) { f.plusSpace(strconv.Ftoa64(v, 'g', doPrec(f, -1))) }
+func (f *fmt) fmt_g64(v float64) { f.plusSpace(strconv.FormatFloat(v, 'g', doPrec(f, -1), 64)) }
// fmt_g64 formats a float64 in the 'f' or 'E' form according to size.
-func (f *fmt) fmt_G64(v float64) { f.plusSpace(strconv.Ftoa64(v, 'G', doPrec(f, -1))) }
+func (f *fmt) fmt_G64(v float64) { f.plusSpace(strconv.FormatFloat(v, 'G', doPrec(f, -1), 64)) }
// fmt_fb64 formats a float64 in the form -123p3 (exponent is power of 2).
-func (f *fmt) fmt_fb64(v float64) { f.plusSpace(strconv.Ftoa64(v, 'b', 0)) }
+func (f *fmt) fmt_fb64(v float64) { f.plusSpace(strconv.FormatFloat(v, 'b', 0, 64)) }
// float32
// cannot defer to float64 versions
// because it will get rounding wrong in corner cases.
// fmt_e32 formats a float32 in the form -1.23e+12.
-func (f *fmt) fmt_e32(v float32) { f.plusSpace(strconv.Ftoa32(v, 'e', doPrec(f, 6))) }
+func (f *fmt) fmt_e32(v float32) { f.plusSpace(strconv.FormatFloat(float64(v), 'e', doPrec(f, 6), 32)) }
// fmt_E32 formats a float32 in the form -1.23E+12.
-func (f *fmt) fmt_E32(v float32) { f.plusSpace(strconv.Ftoa32(v, 'E', doPrec(f, 6))) }
+func (f *fmt) fmt_E32(v float32) { f.plusSpace(strconv.FormatFloat(float64(v), 'E', doPrec(f, 6), 32)) }
// fmt_f32 formats a float32 in the form -1.23.
-func (f *fmt) fmt_f32(v float32) { f.plusSpace(strconv.Ftoa32(v, 'f', doPrec(f, 6))) }
+func (f *fmt) fmt_f32(v float32) { f.plusSpace(strconv.FormatFloat(float64(v), 'f', doPrec(f, 6), 32)) }
// fmt_g32 formats a float32 in the 'f' or 'e' form according to size.
-func (f *fmt) fmt_g32(v float32) { f.plusSpace(strconv.Ftoa32(v, 'g', doPrec(f, -1))) }
+func (f *fmt) fmt_g32(v float32) { f.plusSpace(strconv.FormatFloat(float64(v), 'g', doPrec(f, -1), 32)) }
// fmt_G32 formats a float32 in the 'f' or 'E' form according to size.
-func (f *fmt) fmt_G32(v float32) { f.plusSpace(strconv.Ftoa32(v, 'G', doPrec(f, -1))) }
+func (f *fmt) fmt_G32(v float32) { f.plusSpace(strconv.FormatFloat(float64(v), 'G', doPrec(f, -1), 32)) }
// fmt_fb32 formats a float32 in the form -123p3 (exponent is power of 2).
-func (f *fmt) fmt_fb32(v float32) { f.padString(strconv.Ftoa32(v, 'b', 0)) }
+func (f *fmt) fmt_fb32(v float32) { f.padString(strconv.FormatFloat(float64(v), 'b', 0, 32)) }
// fmt_c64 formats a complex64 according to the verb.
func (f *fmt) fmt_c64(v complex64, verb rune) {
}
}
tok := s.scanNumber(digits, haveDigits)
- i, err := strconv.Btoi64(tok, base)
+ i, err := strconv.ParseInt(tok, base, 64)
if err != nil {
s.error(err)
}
base, digits, haveDigits = s.scanBasePrefix()
}
tok := s.scanNumber(digits, haveDigits)
- i, err := strconv.Btoui64(tok, base)
+ i, err := strconv.ParseUint(tok, base, 64)
if err != nil {
s.error(err)
}
if p := strings.Index(str, "p"); p >= 0 {
// Atof doesn't handle power-of-2 exponents,
// but they're easy to evaluate.
- f, err := strconv.AtofN(str[:p], n)
+ f, err := strconv.ParseFloat(str[:p], n)
if err != nil {
// Put full string into error.
if e, ok := err.(*strconv.NumError); ok {
}
return math.Ldexp(f, n)
}
- f, err := strconv.AtofN(str, n)
+ f, err := strconv.ParseFloat(str, n)
if err != nil {
s.error(err)
}
func TestHexDecode(t *testing.T) {
for i := 0; i < 0x200000; i += 101 /* coprime with 16 */ {
- s := strconv.Itob(i, 16)
+ s := strconv.FormatInt(int64(i), 16)
if got := int(hexDecode([]byte(s))); got != i {
t.Errorf("%s: want %d but got %d", s, i, got)
}
// also rejected.
mw, mh := int64(m.Bounds().Dx()), int64(m.Bounds().Dy())
if mw <= 0 || mh <= 0 || mw >= 1<<32 || mh >= 1<<32 {
- return FormatError("invalid image size: " + strconv.Itoa64(mw) + "x" + strconv.Itoa64(mw))
+ return FormatError("invalid image size: " + strconv.FormatInt(mw, 10) + "x" + strconv.FormatInt(mw, 10))
}
var e encoder
r.Host = params["HTTP_HOST"]
if lenstr := params["CONTENT_LENGTH"]; lenstr != "" {
- clen, err := strconv.Atoi64(lenstr)
+ clen, err := strconv.ParseInt(lenstr, 10, 64)
if err != nil {
return nil, errors.New("cgi: bad CONTENT_LENGTH in environment: " + lenstr)
}
if cr.err != nil {
return
}
- cr.n, cr.err = strconv.Btoui64(line, 16)
+ cr.n, cr.err = strconv.ParseUint(line, 16, 64)
if cr.err != nil {
return
}
return 0, nil
}
- head := strconv.Itob(len(data), 16) + "\r\n"
+ head := strconv.FormatInt(int64(len(data)), 16) + "\r\n"
if _, err = io.WriteString(cw.Wire, head); err != nil {
return 0, err
w.Header().Set("Accept-Ranges", "bytes")
if w.Header().Get("Content-Encoding") == "" {
- w.Header().Set("Content-Length", strconv.Itoa64(size))
+ w.Header().Set("Content-Length", strconv.FormatInt(size, 10))
}
w.WriteHeader(code)
if start == "" {
// If no start is specified, end specifies the
// range start relative to the end of the file.
- i, err := strconv.Atoi64(end)
+ i, err := strconv.ParseInt(end, 10, 64)
if err != nil {
return nil, errors.New("invalid range")
}
r.start = size - i
r.length = size - r.start
} else {
- i, err := strconv.Atoi64(start)
+ i, err := strconv.ParseInt(start, 10, 64)
if err != nil || i > size || i < 0 {
return nil, errors.New("invalid range")
}
// If no end is specified, range extends to end of the file.
r.length = size - r.start
} else {
- i, err := strconv.Atoi64(end)
+ i, err := strconv.ParseInt(end, 10, 64)
if err != nil || r.start > i {
return nil, errors.New("invalid range")
}
if cr.err != nil {
return
}
- cr.n, cr.err = strconv.Btoui64(line, 16)
+ cr.n, cr.err = strconv.ParseUint(line, 16, 64)
if cr.err != nil {
return
}
return 0, nil
}
- head := strconv.Itob(len(data), 16) + "\r\n"
+ head := strconv.FormatInt(int64(len(data)), 16) + "\r\n"
if _, err = io.WriteString(cw.Wire, head); err != nil {
return 0, err
// Profile responds with the pprof-formatted cpu profile.
// The package initialization registers it as /debug/pprof/profile.
func Profile(w http.ResponseWriter, r *http.Request) {
- sec, _ := strconv.Atoi64(r.FormValue("seconds"))
+ sec, _ := strconv.ParseInt(r.FormValue("seconds"), 10, 64)
if sec == 0 {
sec = 30
}
if err == nil {
word = word[0 : len(word)-1] // trim +
}
- pc, _ := strconv.Btoui64(string(word), 0)
+ pc, _ := strconv.ParseUint(string(word), 0, 64)
if pc != 0 {
f := runtime.FuncForPC(uintptr(pc))
if f != nil {
var contentLength int64
if clenStr := w.header.Get("Content-Length"); clenStr != "" {
var err error
- contentLength, err = strconv.Atoi64(clenStr)
+ contentLength, err = strconv.ParseInt(clenStr, 10, 64)
if err == nil {
hasCL = true
} else {
// TransferEncoding)
if t.shouldSendContentLength() {
io.WriteString(w, "Content-Length: ")
- _, err = io.WriteString(w, strconv.Itoa64(t.ContentLength)+"\r\n")
+ _, err = io.WriteString(w, strconv.FormatInt(t.ContentLength, 10)+"\r\n")
if err != nil {
return
}
// Logic based on Content-Length
cl := strings.TrimSpace(header.Get("Content-Length"))
if cl != "" {
- n, err := strconv.Atoi64(cl)
+ n, err := strconv.ParseInt(cl, 10, 64)
if err != nil || n < 0 {
return -1, &badStringError{"bad Content-Length", cl}
}
if _, err := io.ReadFull(qd.r, qd.scratch[:2]); err != nil {
return 0, err
}
- x, err := strconv.Btoi64(string(qd.scratch[:2]), 16)
+ x, err := strconv.ParseInt(string(qd.scratch[:2]), 16, 64)
if err != nil {
return 0, fmt.Errorf("mail: invalid RFC 2047 encoding: %q", qd.scratch[:2])
}
}
case '.', '+', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- v, err := strconv.Btoi64(word, 0)
+ v, err := strconv.ParseInt(word, 0, 64)
if err == nil {
args[i] = v
} else {
- v, err := strconv.Atof64(word)
+ v, err := strconv.ParseFloat(word, 64)
args[i], lerr = v, err
}
typ := val.Type()
switch val.Kind() {
case Int, Int8, Int16, Int32, Int64:
- return strconv.Itoa64(val.Int())
+ return strconv.FormatInt(val.Int(), 10)
case Uint, Uint8, Uint16, Uint32, Uint64, Uintptr:
- return strconv.Uitoa64(val.Uint())
+ return strconv.FormatUint(val.Uint(), 10)
case Float32, Float64:
- return strconv.Ftoa64(val.Float(), 'g', -1)
+ return strconv.FormatFloat(val.Float(), 'g', -1, 64)
case Complex64, Complex128:
c := val.Complex()
- return strconv.Ftoa64(real(c), 'g', -1) + "+" + strconv.Ftoa64(imag(c), 'g', -1) + "i"
+ return strconv.FormatFloat(real(c), 'g', -1, 64) + "+" + strconv.FormatFloat(imag(c), 'g', -1, 64) + "i"
case String:
return val.String()
case Bool:
return typ.String() + "(" + valueToString(val.Elem()) + ")"
case Func:
v := val
- return typ.String() + "(" + strconv.Uitoa64(uint64(v.Pointer())) + ")"
+ return typ.String() + "(" + strconv.FormatUint(uint64(v.Pointer()), 10) + ")"
default:
panic("valueToString: can't print type " + typ.String())
}
}
func u32(i uint32) string {
- return strconv.Uitoa64(uint64(i))
+ return strconv.FormatUint(uint64(i), 10)
}
func dumpInst(b *bytes.Buffer, i *Inst) {
default:
if r < 0x100 {
b.WriteString(`\x`)
- s := strconv.Itob(int(r), 16)
+ s := strconv.FormatInt(int64(r), 16)
if len(s) == 1 {
b.WriteRune('0')
}
break
}
b.WriteString(`\x{`)
- b.WriteString(strconv.Itob(int(r), 16))
+ b.WriteString(strconv.FormatInt(int64(r), 16))
b.WriteString(`}`)
}
}
}
// Imaginary constants can only be complex unless they are zero.
if len(text) > 0 && text[len(text)-1] == 'i' {
- f, err := strconv.Atof64(text[:len(text)-1])
+ f, err := strconv.ParseFloat(text[:len(text)-1], 64)
if err == nil {
n.IsComplex = true
n.Complex128 = complex(0, f)
}
}
// Do integer test first so we get 0x123 etc.
- u, err := strconv.Btoui64(text, 0) // will fail for -0; fixed below.
+ u, err := strconv.ParseUint(text, 0, 64) // will fail for -0; fixed below.
if err == nil {
n.IsUint = true
n.Uint64 = u
}
- i, err := strconv.Btoi64(text, 0)
+ i, err := strconv.ParseInt(text, 0, 64)
if err == nil {
n.IsInt = true
n.Int64 = i
n.IsFloat = true
n.Float64 = float64(n.Uint64)
} else {
- f, err := strconv.Atof64(text)
+ f, err := strconv.ParseFloat(text, 64)
if err == nil {
n.IsFloat = true
n.Float64 = f
t.Errorf("%s: bad second: %d not %d", test.name, time.Second(), 57)
}
// Nanoseconds must be checked against the precision of the input.
- nanosec, err := strconv.Atoui("012345678"[:test.fracDigits] + "000000000"[:9-test.fracDigits])
+ nanosec, err := strconv.ParseUint("012345678"[:test.fracDigits]+"000000000"[:9-test.fracDigits], 10, 0)
if err != nil {
panic(err)
}
if len(field) != NumField {
logger.Fatalf("%5s: %d fields (expected %d)\n", line, len(field), NumField)
}
- point, err := strconv.Btoui64(field[FCodePoint], 16)
+ point, err := strconv.ParseUint(field[FCodePoint], 16, 64)
if err != nil {
logger.Fatalf("%.5s...: %s", line, err)
}
if s == "" {
return 0
}
- v, err := strconv.Btoui64(s, 16)
+ v, err := strconv.ParseUint(s, 16, 64)
if err != nil {
char.dump(cas)
logger.Fatalf("%U: bad letter(%s): %s", char.codePoint, s, err)
// Only care about 'common' and 'simple' foldings.
continue
}
- p1, err := strconv.Btoui64(field[0], 16)
+ p1, err := strconv.ParseUint(field[0], 16, 64)
if err != nil {
logger.Fatalf("CaseFolding.txt %.5s...: %s", line, err)
}
- p2, err := strconv.Btoui64(field[2], 16)
+ p2, err := strconv.ParseUint(field[2], 16, 64)
if err != nil {
logger.Fatalf("CaseFolding.txt %.5s...: %s", line, err)
}
if len(matches) != 4 {
logger.Fatalf("%s: %d matches (expected 3)\n", line, len(matches))
}
- lo, err := strconv.Btoui64(matches[1], 16)
+ lo, err := strconv.ParseUint(matches[1], 16, 64)
if err != nil {
logger.Fatalf("%.5s...: %s", line, err)
}
hi := lo
if len(matches[2]) > 2 { // ignore leading ..
- hi, err = strconv.Btoui64(matches[2][2:], 16)
+ hi, err = strconv.ParseUint(matches[2][2:], 16, 64)
if err != nil {
logger.Fatalf("%.5s...: %s", line, err)
}
key2, number2 := generateKeyNumber()
if config.handshakeData != nil {
key1 = config.handshakeData["key1"]
- n, err := strconv.Atoui(config.handshakeData["number1"])
+ n, err := strconv.ParseUint(config.handshakeData["number1"], 10, 32)
if err != nil {
panic(err)
}
number1 = uint32(n)
key2 = config.handshakeData["key2"]
- n, err = strconv.Atoui(config.handshakeData["number2"])
+ n, err = strconv.ParseUint(config.handshakeData["number2"], 10, 32)
if err != nil {
panic(err)
}
ok := true
for i := 0; i < len(tests); i++ {
t := tests[i]
- v := strconv.Ftoa64(t.f, 'g', -1)
+ v := strconv.FormatFloat(t.f, 'g', -1, 64)
if v != t.out {
println("Bad float64 const:", t.in, "want", t.out, "got", v)
- x, err := strconv.Atof64(t.out)
+ x, err := strconv.ParseFloat(t.out, 64)
if err != nil {
println("bug120: strconv.Atof64", t.out)
panic("fail")
}
- println("\twant exact:", strconv.Ftoa64(x, 'g', 1000))
- println("\tgot exact: ", strconv.Ftoa64(t.f, 'g', 1000))
+ println("\twant exact:", strconv.FormatFloat(x, 'g', 1000, 64))
+ println("\tgot exact: ", strconv.FormatFloat(t.f, 'g', 1000, 64))
ok = false
}
}
report := len(os.Args) > 1
status := 0
var b1 [10]T1
- a0, _ := strconv.Btoui64(fmt.Sprintf("%p", &b1[0])[2:], 16)
- a1, _ := strconv.Btoui64(fmt.Sprintf("%p", &b1[1])[2:], 16)
+ a0, _ := strconv.ParseUint(fmt.Sprintf("%p", &b1[0])[2:], 16, 64)
+ a1, _ := strconv.ParseUint(fmt.Sprintf("%p", &b1[1])[2:], 16, 64)
if a1 != a0+1 {
fmt.Println("FAIL")
if report {
status = 1
}
var b2 [10]T2
- a0, _ = strconv.Btoui64(fmt.Sprintf("%p", &b2[0])[2:], 16)
- a1, _ = strconv.Btoui64(fmt.Sprintf("%p", &b2[1])[2:], 16)
+ a0, _ = strconv.ParseUint(fmt.Sprintf("%p", &b2[0])[2:], 16, 64)
+ a1, _ = strconv.ParseUint(fmt.Sprintf("%p", &b2[1])[2:], 16, 64)
if a1 != a0+2 {
if status == 0 {
fmt.Println("FAIL")
}
}
var b4 [10]T4
- a0, _ = strconv.Btoui64(fmt.Sprintf("%p", &b4[0])[2:], 16)
- a1, _ = strconv.Btoui64(fmt.Sprintf("%p", &b4[1])[2:], 16)
+ a0, _ = strconv.ParseUint(fmt.Sprintf("%p", &b4[0])[2:], 16, 64)
+ a1, _ = strconv.ParseUint(fmt.Sprintf("%p", &b4[1])[2:], 16, 64)
if a1 != a0+4 {
if status == 0 {
fmt.Println("FAIL")