casts and assignments

Henry Spencer henry at utzoo.uucp
Wed Dec 6 04:38:50 AEST 1989


In article <3979 at vax1.tcd.ie> mbrennan at vax1.tcd.ie writes:
>>>... I am led to believe that all assignments include an implicit cast
>>>such that:
>>>	a = (type of 'a') (expression);
>>>Is exactly equivalent in ALL cases to:
>>>	a = (expression);
>>>Is this true?
>
>int i ;
>int j ;
>long l ;
>
>	l = i * j ;
>	l = (long) i * j ;
>
>I realise I may be answering a slightly different question than you posed... 

You are answering a *completely* different question.  Notice that he put
parentheses around the expression, which eliminates the problem you mention
(`(long)i * j' means `((long)i) * j' not `(long)(i * j)').
-- 
Mars can wait:  we've barely   |     Henry Spencer at U of Toronto Zoology
started exploring the Moon.    | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list