I have a situation where I need to convert a binary value to hex in Ruby. My situation is as follows:
When bin = "0000111", my output should be: hex = "07".
When bin = "010001111", my output should be: hex = "08f".
Could someone help me out on how to do this? Thanks in advance.
How about:
Edit: if you don’t want the output to be
0x..but just0..leave out the firstxin the format string.