% operator with negatives

Karl Heuer karl at ima.isc.com
Fri Dec 14 17:43:05 AEST 1990


In article <18140 at neptune.inf.ethz.ch> brandis at inf.ethz.ch (Marc Brandis) writes:
>Did somebody ever try it on the VAX? A guy told me once that integer division
>rounds toward zero on the VAX while the MOD instruction delivers always a
>positive result...

Sounds like you're refering to what the Pascal compiler does, rather than
the machine language.  When I first encountered the VAX, one of my first
complaints was that it didn't *have* a 32-bit MOD instruction (or
equivalently, a DIV that generated remainder as well as quotient).  The
compiler must either generate a-(a/b)*b, or extend a into a double word% and
use the 64-bit EDIV (which *does* generate both quotient and remainder).

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint
% DEC, out of loyalty to their 16-bit line, called their halfwords `words'
  and so they called this thing a `quadword'.



More information about the Comp.lang.c mailing list