RosettaCodeData/Task/Non-decimal-radices-Input/Ruby/non-decimal-radices-input-4.rb
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00:00

6 lines
287 B
Ruby

p dec1.to_i(0) # => 5349 (which is 12345 in octal, the 9 is discarded)
p ("0d" + dec1).to_i(0) # => 123459
p ("0x" + hex2).to_i(0) # => 180154659
p ("0" + oct3).to_i(0) # => 4009
p ("0o" + oct3).to_i(0) # => 4009
p ("0b" + bin4).to_i(0) # => 345