I’m curious what’s the best way to convert hexadecimal string to binary string in Ruby.
I.e.
def get_binary_string( hex_string )
# what's the best way?
end
puts get_binary_string("2F")
output> "00101111"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could convert the hex
2Fto an integer (47), and then convert it back to a binary string (101111):