right, I am trying to do a task where I should convert 2A45 to a pair of ascii characters, however the presence of the "A" (10) confuses me- if I convert it to decimal I get 10821 which is 5 characters not 4.

Recommended Answers

All 2 Replies

You're converting the whole number of to dec, there's a "pair" of characters in there.

Not sure I follow you but I will try to explain. This sounds like a homework question so I will not give you the answere but will try to lead you in the right direction. Each hex digit represents four binary bits. So that means two hex digits represent 8 bits or one byte, which is what you need to represent an ascii character. so the hex number you listed is a pair of ascii characters, 2A and 45. If you can convert those to integers and look them up in the ascii table you will have your answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.