I am trying to write a program in Java that takes in someons hexidecimal input. To make it eaiser I just want to do two digit hex. So they put in A2, and then I want the binary output for that. What I do know how to do is put a decimal to binary, so I wanted to try and say okay put A to be 10 in decimal, and 2 to be...well 2 in decimal. break the two into 4 bit arrays and do the binary for each, then comibe each togther into an 8 bit array and thats the binary, then from there I could try and do decimal, and octal by multipliying the necessary 1*2^(slot position) etc. My problem is figuring out how the hell to tell the computer that A means 10 and F means 15. I have no idea how to write this bloody thing. If anyone knows I woudl greatly appreciate, i've been trying to google it with less than satisfactory results.
All 7 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.