9

There is a sentence in C Primer Plus that I can hardly understand.

C automatically expands type float values to type double when they are passed as arguments to any function, such as printf().

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

0 Answers0