| ??? 04/14/06 06:24 Read: times |
#114287 - ASCII Coding Responding to: ???'s previous message |
First, we need to be clear that ASCII has nothing to do with numbers. ASCII is a numerical code for representing characters for use in printers, on displays, etc.
ASCII is not used for arithmetic! In ASCII, the numerical value thirty-two represents a 'space' character; the numerical value sixty-five represents an uppercase 'A' character; the numerical value ninety-nine represents a lowercase 'c' character; the numerical value fifty represents a character '2'; etc, etc,... We can write those numerical values in various formats, including binary, decimal, and hexadecimal - so the above paragraph can be re-stated as:
Decimal 'C' Hexadecimal Binary ASCII-Coded
Number Representation Representation Representation Character
----------- -------------- -------------- -------------- -----------
thirty-two 32 0x20 00100000 ' '
sixty-five 65 0x41 01000001 'A'
ninety-nine 99 0x63 01100011 'c'
fifty 50 0x32 00110010 '2'Now, if you look at the ASCII codes for the digit characters '0' to '9', you should spot a simple relationsip between the numerical value of the ASCII code, and the digit that it represents:
ASCII Character Code --------- ----- '0' 0x30 '1' 0x31 '2' 0x32 '3' 0x33 '4' 0x34 '5' 0x35 '6' 0x36 '7' 0x37 '8' 0x38 '9' 0x39 Thus, to convert a numerical value 0-9 into its corresponding ASCII-code value, you simply add (not "AND") 0x30. For multiple digits, you need to apply this conversion to each digit - that's where the division by 10, 100, etc comes in. For a review of the basic principles of radix notation (different number bases), take a look at the excellent MathForum article cited recently by David Mars: http://www.8052.com/forum/read.phtml?id=94177 In fact, while you're there, it'd be well worth looking through the other MathForum articles on the subject... http://www.8052.com/forum/read.phtml?id=94478 http://www.8052.com/forum/read.phtml?id=96256 |
| Topic | Author | Date |
| neail's alagothram | 01/01/70 00:00 | |
| OK | 01/01/70 00:00 | |
| ASCII Coding | 01/01/70 00:00 | |
| Please make it descriptive | 01/01/70 00:00 | |
| I wrote this when I must just learning | 01/01/70 00:00 | |
| THERE SOME PROBLEM | 01/01/70 00:00 | |
| DON'T SHOUT! | 01/01/70 00:00 | |
soory for | 01/01/70 00:00 |



