float data type(5.0) being assigned 8 bytes rather that 4 using sizeof operator in C -


why sizeof(5.0) return 8 output rather 4 machine allocates 4 bytes float data type? default consider 5.0 double (memory allocated = 8 bytes), if yes why so?

because floating point literals default double. if want float use f suffix in 5.0f.

read e.g. this floating point constant (literal) reference more information.


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -