Type casting problem

Kevin Shallow sourjan@yahoo.com
Fri Jun 8 05:38:00 GMT 2001


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/



More information about the Gcc-help mailing list