How can I take a hexadecimal number as input? I don’t mean to take an integer as input and convert it to hexadecimal, but to take a hexadecimal number as input.
Share
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.
To read a hex number from standard input and parse:
gets.to_i(16). I think what you really meant to ask was how to do this:Ruby defaults all parsing/printing to decimal; you have to be explicit if you want hex.