c - What is the type of the value 1.0e+1 -


does 1.0e+1 return float value or int value?

when print 1.0e+1 gives 10 when sizeof(1.0e+1) gives me 8.

does 1.0e+1 return float value or int value?

ans: none. written, represents double.

nitpick: let's use term represent instead of return

i think you're confused. ihmo, need know proper usage of conversion specifiers.

  1. to print float, need use %f
  2. to print sizeof output, need use %zu

that said, printing 1.0e+1 means printing value whereas, sizeof(1.0e+1) sizeof(double), because, floating point literal default double.

related, c11 standard, chapter §6.4.4.2

an unsuffixed floating constant has type double. if suffixed letter f or f, has type float. if suffixed letter ``l or l, has type long double.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -