linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Learner <ruxyz@yahoo.com>
To: "Gerardo  \"García\" \"Peña\"" <gerardo@kung-foo.dhs.org>
Cc: Linux Kernel Newbie <kernelnewbies@nl.linux.org>,
	Assembly Linux <linux-assembly@vger.kernel.org>
Subject: Re: OFF-TOPIC : Confusion about basic C program behaviour
Date: Mon, 14 Mar 2005 01:05:38 -0800 (PST)	[thread overview]
Message-ID: <20050314090538.86802.qmail@web41127.mail.yahoo.com> (raw)
In-Reply-To: 6667

Thank you for the useful link .

--- Gerardo García Peña <gerardo@kung-foo.dhs.org>
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/ 

             reply	other threads:[~2005-03-14  9:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-14  9:05 Learner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-03-10 11:54 OFF-TOPIC : Confusion about basic C program behaviour Learner
2005-03-10 16:23 ` Robert G. Plantz
2005-03-10 10:00 Learner
2005-03-10 11:07 ` Stephen Ray
2005-03-10 11:39   ` Bharanidharan S
2005-03-10 11:44   ` Bharanidharan S

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050314090538.86802.qmail@web41127.mail.yahoo.com \
    --to=ruxyz@yahoo.com \
    --cc=gerardo@kung-foo.dhs.org \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).