The printf function is very handy, but very memory consuming when all the data types
are simultaneously supported. For this reason, the support for 32 bit integers and floating point numbers must be explicitely enabled to become active. If you need this support, just #
define the macros INT32_IO
and/or FLOAT_IO
when stdio.c
is compiled19.
Specifier | Data types of parameter | Support |
%c |
int, char | always |
%s |
char *, int *, etc. | always |
%d |
int, char | always |
%u |
unsigned int, unsigned char | always |
%x |
int, char, unsigned int, unsigned char | always |
%ld |
long | always |
%lu |
unsigned long | always |
%lx |
long, unsigned long | always |
%lld |
long long | INT32_IO defined |
%llu |
unsigned long long | INT32_IO defined |
%llx |
long long, unsigned long long | INT32_IO defined |
%f |
float (standard notation) | FLOAT_IO defined |
%e |
float (scientific e notation) | FLOAT_IO defined |
%E |
float (scientific E notation) | FLOAT_IO defined |
In order to save memory, printf() do not support minimal width specifiers, such as %3ld
.
However, a precision specifier is supported for %f
%e
and %E
. For example,
%3e
ask printf()
to print 3 decimal digits after the decimal point. The specified precision can range from 0 to 7 (that is the default value).
Remember that the number of significant digits is 6 or 7 for the IEEE-754 floating point numbers.
For example, printing
with more than 3 digits after the decimal point doesn't make sense because the least significant written digits do not represent anything in the result.