Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: long conversion of short expression. Message-ID: <10634@smoke.BRL.MIL> Date: 31 Jul 89 13:49:21 GMT References: <9092@chinet.chi.il.us> <869@fiasco.sco.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 12 In article <869@fiasco.sco.COM> md@sco.COM (Michael Davidson) writes: >Neither - the two (short) variables are promoted to (int) before the >multiplication, the result of the multiplication is an (int) ... >Of course your compiler can generate any code it likes provided that >it gets the answer which is "correct" according to these rules. Oops, Michael is correct. I misstated this in an earlier response. The "usual arithmetic conversions" are applied to the operands before the operation occurs, and the result has the common promoted type. Anyway, the important point is that the programmer needs to use explicit casts to force the shorts to longs if the result might not fit in a short.