[M3devel] Arithmetic Shift

dirk muysers 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) =
  BEGIN
    WHILE x < –64 OR x > 63 DO
      Write (VAL (i MOD 128 + 128, CHAR));
      i := i DIV 128;
    END;
    Write (VAL (i MOD 128), CHAR));
  END Write;

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...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20150704/1b90114c/attachment-0001.html>


More information about the M3devel mailing list