# title=Fundamentals of Data Representation: Character form of decimal digit

 ← Floating point errors Character form of decimal digit ASCII and unicode →

Binary patterns are used to represent more than just numbers. They can be for characters, text, sounds and images.

All the characters on the keyboard can be given a character code which can be represented as a binary pattern inside the computer. They can be:

• Numbers
• Letters (capitals and lower case are separate)
• Punctuation (?/|\£\$ etc.)
• non-printing commands (enter, escape, F1)

You will find out about two different character code systems (ASCII and Unicode) on the next page.

 From the Specification : Introduction to Principles of Computation Differentiate between the character code representation of a decimal digit and its pure binary representation.

It is important that you can tell the difference between the binary representation of a decimal number and the different binary pattern for that number when it is stored as a character.

Numerical digits have different binary patterns depending on if they are stored as characters or numbers -

## Example

Using ASCII the character digits 0 to 9 are assigned the decimal number codes 48 to 57.

The string or character digits 46 are represented in ASCII as 00110100 00110110. This is worked out as the ASCII for the character 4 is the denary code 52 which is 00110100; and the ASCII for the character 6 is 54 which is 00110110.

Whereas the decimal number 46 if stored in a 16-bit word is 00000000 00101110. This is worked out as with all binary to decimal conversions as 32 + 8 + 4 + 2 = 46

 Exercise: Building circuits What is the decimal number 42 as a 16 bit binary pattern? Answer: The number 42 = 32 + 8 + 2, so in binary 00000000 00101010. If in ASCII the character digit 4 is given the number code 52, what is the string 42 in binary? Answer: The string 42 is made up of the characters 4 and 2. If 4 is the ASCII code 52 then 2 should be 50, so calculate binary pattern for 52 and then 50. 52 = 32 + 16 + 4, so 00110100 50 = 32 + 16 + 2, so 00110010, therefore the answer is 00110100 00110010 Convert the number 27 into a 16 bit binary pattern. Answer: The number 27 = 16 + 8 + 2 + 1, so in binary 00000000 00011011. What is the string 27 as a binary pattern? Note: the ASCII code for the character 0 is 48. Answer: The string 27 is made up of the characters 2 and 7. If 0 is the ASCII code 48 then 2 will be 50 and 7 will be 55. Therefore calculate binary pattern for 50 and then 55. 50 = 32 + 16 + 2, so 00110010, 55 = 32 + 16 + 4 + 2 + 1, so 00110111, therefore the answer is 00110010 00110111