This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Type casting problem
- To: gcc-help at gcc dot gnu dot org
- Subject: Re: Type casting problem
- From: Kevin Shallow <sourjan at yahoo dot com>
- Date: Fri, 8 Jun 2001 05:37:54 -0700 (PDT)
Thank you all for the help. It is most appreciated :)
_Kevin
--- Der Herr Hofrat <der.herr@hofr.at> wrote:
> > >
> > > int main(int argc, char *argv[])
> > > {
> > > double amount;
> > > double cost;
> > > long iamount;
> > >
> > > cost = 0.06;
> > > amount = cost * 100;
> > > iamount = (long)(((double)cost) * 100);
> > >
> > > printf("Amount %lf\n", amount);
> > > printf("Integer Amount %ld\n", iamount);
> > >
> > > return (0);
> > > }
> > >
> > > Here's the output:
> > >
> > > Amount 6.000000
> > > Integer Amount 5
> >
>
> -O2 is the solution
>
> note that this is not realy explicid typcasting
> related (that is implicid
> casts do the same job) , so:
>
> iamount = cost * 100;
>
> will do the same
>
> hofrat
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/