p dec1.to_i(10) # => 123459 p hex2.to_i(16) # => 180154659 p oct3.to_i(8) # => 4009 p bin4.to_i(2) # => 345 p "xyz9".to_i(10) # => 0 If there is not a valid letter, 0 is returned.