0

I need to print on screen a variable value that is encoded in BCD.

Do you know whether is possible to print it on screen by using itoa?

If that is possible, how to do that?

user229044
  • 232,980
  • 40
  • 330
  • 338
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173

1 Answers1

1

No, itoa will not help. You want to look at the hexadecimal representation, so use hex like in cout << hex << n << endl;

Note: BCD codes the digits as 4-bit-sequences 0000 to 1001, which in hexadecimal are 0 to 9. So 23 as BCD would be 0010 0011 bitwise, or in fact as 8bit integer it would be 35, so converting this to a string will not be of much use.

Zane
  • 926
  • 8
  • 21
  • and if you want to know how to print this to a string, look here: http://stackoverflow.com/questions/5100718/int-to-hex-string-in-c – Zane Oct 31 '12 at 13:31