Thank you for the useful link . --- Gerardo García Peña <gerardo@xxxxxxxxxxxxxxxx> wrote: > Learner wrote: > > >Hi, > > > > I know this is not the correct place to post this > >question, but I feel it would be pretty easy for > the > >kernel gurus to explain this. > > > >TEST CODE > >========== > > > >#include <stdio.h> > > > >main() > >{ > > float a1=1.0; > > float a2=2.0; > > > > printf(" \n"); > > printf(" Size of Float > %d \n", sizeof(float) > ); > > printf(" Size of Int > %d \n", sizeof(int) ); > > printf(" \n"); > > > > printf(" CASE 1 : f-f > %f - %f \n\n", a1, a2); > > printf(" CASE 2 : f-d > %f - %d \n\n", a1, a2); > > printf(" CASE 3 : d-f > %d - %f \n\n", a1, a2); > > printf(" CASE 4 : d-d > %d - %d \n\n", a1, a2); > >} > > > >OUTPUT : > > > > Size of Float > 4 > > Size of Int > 4 > > > > CASE 1 : f-f > 1.000000 - 2.000000 > > > > CASE 2 : f-d > 1.000000 - 0 > > > > CASE 3 : d-f > 0 - 0.000000 > > > > CASE 4 : d-d > 0 - 1072693248 > > > >================================== > > > >The CASE1 & CASE2 & CASE4 outputs are expected. > > > > Any explanation for CASE3 behaviour. > > I presume it should behave similar to CASE2 and > >print 0 - 2.000000 . > > > > Could somebody please pin-point what is > >lacking in my presumtion . > > > >Thanks ! > > > > > > > I believe this happens because float is promoted to > double when it is > passed as an arg... so you should think that double > = 8 and int = 4. > > I have been googling and I have found this: > > > http://www-ccs.ucsd.edu/c/function.html#argument%20promotion > > __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/