The binary world and the ASCII world in ANSI C
When using high level programming languages and, specifically, ANSI C, computers store in its memory the variables that are used within a program in basic binary formats. Such is the case of positive integer variables, signed integer and floating point variables. The latter are stored in a format of 4 bytes, using the IEEE-754 standard.
This allows performing arithmetic, logic or digital processing between variables during the execution of a program quickly with binary algorithms.
However, in every program there is a communication between the microcontroller and the external world devices, and more specifically with human beings, in the so called "Human Machine Interface". This communication takes place usually in ASCII format.
ASCII formats are used in the C program by defining variables of type "char" or arrays called "strings".
The ANSI C language and specifically the C18 compiler, provides users with standard library functions which can convert the binary to ASCII and viceversa, as shown in the illustration.
When a programmer wants to send or display the value of a variable to the external world, he will use binary-ASCII conversion functions, as sprintf( ) or printf( ).
Alternatively, when data is entered into the microcontroller from the external world, conversion functions ASCII-binary atoi( ), atol( ) or atof( ) are used.