PeÃ±a, Botp wrote:

## ------------------------------------------------------------ Fixnum#to_s

fix.to_s( base=10 ) -> aString

```
Returns a string containing the representation of _fix_ radix
_base_ (between 2 and 36).
```

## …

------------------------------------------------------------ String#to_i

str.to_i(base=10) => integer

```
Returns the result of interpreting leading characters in _str_ as
an integer base _base_ (2, 8, 10, or 16).
```

I recognized that the documentation for “String#to_i” is somehow

“incomplete”, because it works like “Fixnum#to_s” for a base between 2

and 36:

irb(main):001:0> “gdfhjk”.to_i(35)

=> 860522760

irb(main):002:0> “gdfhjk”.to_i(36)

=> 990016400

irb(main):003:0> “gdfhjk”.to_i(37)

ArgumentError: illegal radix 37

from (irb):3:in `to_i’

from (irb):3

In details for each possible base:

the_number = 10101010101010

(2…36).each do |bas|

if the_number.to_s(bas).to_i(bas) == the_number

puts “base #{bas} works (#{the_number.to_s(bas)})”

else

puts “base #{bas} does not work”

end

end

The result is:

base 2 works (10010010111111010011000111100111001100010010)

base 3 works (1022202122110202120001011121)

base 4 works (2102333103013213030102)

base 5 works (2310443332041213020)

base 6 works (33252201234032454)

base 7 works (2061526306133563)

base 8 works (222772307471422)

base 9 works (38678422501147)

base 10 works (10101010101010)

base 11 works (32448a5961a44)

base 12 works (1171787a1872a)

base 13 works (5836a100096a)

base 14 works (26cc6a3aa16a)

base 15 works (127b3cba6baa)

base 16 works (92fd31e7312)

base 17 works (50304bdeb05)

base 18 works (2egahdbedfg)

base 19 works (1c5e59eg4h9)

base 20 works (jeb85d2caa)

base 21 works (cf15igbbba)

base 22 works (881bkk72d4)

base 23 works (5dmfc043lj)

base 24 works (3ji88medja)

base 25 works (2g4nialbfa)

base 26 works (1m9g6neiga)

base 27 works (18khckf14g)

base 28 works (qkh66m7aa)

base 29 works (k5gfamce8)

base 30 works (fbptcp6ka)

base 31 works (bq4bh2she)

base 32 works (95v9hssoi)

base 33 works (760b79154)

base 34 works (5manpab8m)

base 35 works (4gyu22bfa)

base 36 works (3kwc8m3gy)

This means, that the documentation should be changed a little bit.

Wolfgang NÃ¡dasi-Donner