Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!gem.mps.ohio-state.edu!ctrsol!emory!cambridge.apple.com!bloom-beacon!eru!luth!sunic!mcsun!ukc!tcdcs!csvax1.cs.tcd.ie!swift.cs.tcd.ie!vax1.tcd.ie!mbrennan From: mbrennan@vax1.tcd.ie Newsgroups: comp.lang.c Subject: Re: casts and assignments Message-ID: <3979@vax1.tcd.ie> Date: 4 Dec 89 17:39:39 GMT References: <6589@arcturus> <21033@mimsy.umd.edu> Organization: Computer Laboratory, Trinity College Dublin Lines: 32 In article <21033@mimsy.umd.edu>, chris@mimsy.umd.edu (Chris Torek) writes: > In article <6589@arcturus> evil@arcturus.UUCP (Wade Guthrie) 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, but ... The above two statements will not yeild the same result, because in the first instance the int's i and j are multiplied and the result stored in an unnamed temp of type int. In the second case however i is coerced to long first. Then before multiplication can take place j is promoted to the same type(long). This means the result of the multiplication is held in an unnamed temp of type long thus ensuring no loss of significant digits. , , Micheal mbrennan@cs.tcd.ie