This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How Char Numbers work??

I am having trouble understanding what happens in the 8051 Memory when numbers are stored as Char types. As I understand it when the letter A is store as a Char type the memory holds 0x41. When the number 191 is stored as a Char Type I would expect the memory to hold 3 Hex digits in a string starting with 0x31 for the number 1. This is not what happens.In fact 191 is stored as 0XBF which is the Hex value for 191. I don't understand why we bother using numbers as Char if they are stored the same way Int types are stored?? Can someone explain this??

Parents
  • That byte of memory don't care if you assign 0x40 or '@' or 64. The compiler will think it is the same thing.

    If you want to convert a number into the characters that presents the number (so convert the number 64 into the character '6' (0x36) and '4' (0x34) then you can use [s[n]]printf(). Functions like atoi() or strtol() can be used to convert a sequence of character digits into the number the digits forms.

Reply
  • That byte of memory don't care if you assign 0x40 or '@' or 64. The compiler will think it is the same thing.

    If you want to convert a number into the characters that presents the number (so convert the number 64 into the character '6' (0x36) and '4' (0x34) then you can use [s[n]]printf(). Functions like atoi() or strtol() can be used to convert a sequence of character digits into the number the digits forms.

Children
No data