[ create a new paste ] login | about

Link: http://codepad.org/72v0fdaI    [ raw code | output | fork | 9 comments ]

Ruby, pasted on Jun 16:
puts "10進数→指定した進数に変換"
p 255.to_s(2)
p 255.to_s(8)
p 255.to_s(16)
p 255.to_s(10)

puts "指定した進数→10進数に変換"
p 0b10000
p 020
p 0x10

puts "指定した進数→指定した進数に変換"
p 0b10000.to_s(2)
p 0b10000.to_s(8)
p 0b10000.to_s(16)
p 0b10000.to_s(10)
p 020.to_s(2)
p 020.to_s(8)
p 020.to_s(16)
p 020.to_s(10)
p 0x10.to_s(2)
p 0x10.to_s(8)
p 0x10.to_s(16)
p 0x10.to_s(10)


Output:
10進数→指定した進数に変換
"11111111"
"377"
"ff"
"255"
指定した進数→10進数に変換
16
16
16
指定した進数→指定した進数に変換
"10000"
"20"
"10"
"16"
"10000"
"20"
"10"
"16"
"10000"
"20"
"10"
"16"


Create a new paste based on this one


Comments:
posted by dsun511 on May 6
358818040997739
reply
posted by dsun511 on May 6
358818040997739
reply
posted by dsun511 on May 6
d
reply
posted by dsun511 on May 6
p 255.to_s(16)

reply
posted by dsun511 on May 6
43453556456456
reply
posted by dsun511 on May 6
143235445365532
reply
posted by dsun511 on May 6
34554133446575423535
reply
posted by dsun511 on May 6
345541334465754
reply
posted by dsun511 on May 6
434352354623445
reply