Re^2: Turbo C 2.0 vs MSC 5.1

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Aug 10 06:25:03 AEST 1989


In article <527 at tigger.planet.bt.co.uk> raph at tigger.planet.bt.co.uk (Raphael Mankin) writes:
>	int	i, j;
>	long	l;
>	l = i*j;
>MSC will compute i*j as 32 bits, discard the upper 16 bits and then sign
>extend the 16 bits back to 32 bits.

That's acceptable behavior.  If the operands were unsigned, discarding of
the high bits would even be required behavior.

Dealing with, or better yet avoiding, arithmetic overflow is tricky to do
right.  C explicitly does not constrain the implementation's behavior in
such a case, partly because any simple rule would not be universally
appropriate.



More information about the Comp.lang.c mailing list