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
returnfloat
value orint
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.
- to print float, need use
%f
- 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 letterf
orf
, has typefloat
. if suffixed letter ``l orl
, has typelong double
.
Comments
Post a Comment