[M3devel] Arithmetic Shift
dmuysers at hotmail.com
Sat Jul 4 11:48:08 CEST 2015
Why is there no arithmetic right shift operation in Modula-3 ?
Oberon software has a clever way to minimally encode
signed integers independently of their size.
PROCEDURE WriteInt (i: INTEGER) =
WHILE x < –64 OR x > 63 DO
Write (VAL (i MOD 128 + 128, CHAR));
i := i DIV 128;
Write (VAL (i MOD 128), CHAR));
Unfortunately it is impossible to implement the corresponding
decoder in M3, because it requires an arithmetic right shift
where the sign bit is replicated into the left end.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the M3devel