Path: utzoo!attcan!uunet!sco!md From: md@sco.COM (Michael Davidson) Newsgroups: comp.lang.c Subject: Re: long conversion of short expression. Message-ID: <869@fiasco.sco.COM> Date: 30 Jul 89 17:04:36 GMT References: <9092@chinet.chi.il.us> Reply-To: md@sco.COM (Michael Davidson) Organization: The Santa Cruz Operation, Inc. Lines: 14 In article <9092@chinet.chi.il.us> pdg@chinet.chi.il.us (Paul Guthrie) writes: >Here is a case where 68000 compilers don't seem to agree. >In the following code segment, the two shorts multiplied together >exceed the size of a short, but the question is, is the result >of the multiplication really a short to be converted to a >long, or a long already? Neither - the two (short) variables are promoted to (int) before the multiplication, the result of the multiplication is an (int) which gets promoted to a (long) before the addition is performed. Of course your compiler can generate any code it likes provided that it gets the answer which is "correct" according to these rules. (To see why understanding this particular bit of pedantry is important consider what happens on machines with 16 bit shorts, 16 bit ints and 32 bit longs)