Difference between float and double in C


1)      A float datatype allocates 4 byte memory space where double datatype allocates 8 bytes memory space.
2)      A float datatype uses single precision that means it allowed after dot(.) upto 7 digits whereas double datatype uses double precision that means it allowed upto 15 digits after dot.
3)      In C language a fractional value promote into double type. If we want to change a fractional value into float type then fractional value must be postfix by F or f.
Example:-   25.7 --à 8 byte
                        23.9F -à 4 byte
                  45.8f à 4 byte
(i)  printf(“%d”,sizeof(26.7));
output------- 8
(ii)printf(“%d”,sizeof(45.7f));
Output------ 4


Comments

Popular Posts