return x.abs.decimalString()
}
-func charset(ch int) string {
+func charset(ch rune) string {
switch ch {
case 'b':
return lowercaseDigits[0:2]
// output field width, space or zero padding, and left or
// right justification.
//
-func (x *Int) Format(s fmt.State, ch int) {
+func (x *Int) Format(s fmt.State, ch rune) {
cs := charset(ch)
// special cases
// Scan is a support routine for fmt.Scanner; it sets z to the value of
// the scanned number. It accepts the formats 'b' (binary), 'o' (octal),
// 'd' (decimal), 'x' (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
-func (z *Int) Scan(s fmt.ScanState, ch int) os.Error {
+func (z *Int) Scan(s fmt.ScanState, ch rune) os.Error {
s.SkipSpace() // skip leading space characters
base := 0
switch ch {
// MaxBase is the largest number base accepted for string conversions.
const MaxBase = 'z' - 'a' + 10 + 1 // = hexValue('z') + 1
-func hexValue(ch int) Word {
+func hexValue(ch rune) Word {
d := MaxBase + 1 // illegal base
switch {
case '0' <= ch && ch <= '9':
- d = ch - '0'
+ d = int(ch - '0')
case 'a' <= ch && ch <= 'z':
- d = ch - 'a' + 10
+ d = int(ch - 'a' + 10)
case 'A' <= ch && ch <= 'Z':
- d = ch - 'A' + 10
+ d = int(ch - 'A' + 10)
}
return Word(d)
}
x nat // expected nat
b int // expected base
ok bool // expected success
- next int // next character (or 0, if at EOF)
+ next rune // next character (or 0, if at EOF)
}{
// error: illegal base
{base: -1},
return z.norm()
}
-func ratTok(ch int) bool {
+func ratTok(ch rune) bool {
return strings.IndexRune("+-/0123456789.eE", ch) >= 0
}
// Scan is a support routine for fmt.Scanner. It accepts the formats
// 'e', 'E', 'f', 'F', 'g', 'G', and 'v'. All formats are equivalent.
-func (z *Rat) Scan(s fmt.ScanState, ch int) os.Error {
+func (z *Rat) Scan(s fmt.ScanState, ch rune) os.Error {
tok, err := s.Token(true, ratTok)
if err != nil {
return err