16进制到10进制:
>> "B0A0".hex
=> 45216
或
>> "B0A0".to_i(16)
=> 45216
10进制到16进制:
>> 45216.to_s(16)
=> "b0a0"
转载请注明: 转自船长日志, 本文链接地址: http://www.cslog.cn/Content/ruby-hex-dec/
16进制到10进制:
>> "B0A0".hex
=> 45216
或
>> "B0A0".to_i(16)
=> 45216
10进制到16进制:
>> 45216.to_s(16)
=> "b0a0"
转载请注明: 转自船长日志, 本文链接地址: http://www.cslog.cn/Content/ruby-hex-dec/