Turbo C bug !
Doug Gwyn
gwyn at smoke.BRL.MIL
Tue Jan 24 07:08:27 AEST 1989
In article <PK-TLE.89Jan21103247 at shai.sics.se> pk-tle at sics.se (Tommy Levitte) writes:
>(57600 = 240*240 !!!!!!!)
Not with 16-bit ints, it doesn't. 240*240 overflows a 16-bit int,
with generally unpredictable results. Apparently Turbo C treated
the result as -7936, which is what you get on "silent" overflow
on a 2's-complement 16-bit machine. That's permissible. As you
noted, forcing the computation to be done using longs avoids the
overflow.
More information about the Comp.lang.c
mailing list