There is a sentence in C Primer Plus that I can hardly understand.
C automatically expands type
float
values to typedouble
when they are passed as arguments to any function, such asprintf()
.
I feel puzzled because in its former content, multiple data types are introduced, and it seems that by using appropriate data types, you can reach a place where your C programs run most efficiently. For example, in some programs, using short
instead of int
may result in faster running without any cost of function.
Therefore, why does float
automatically change to double
when acting as arguments? Some people say that it's more convenient in this way. However, does such expansion correspond to C's philosophy?