[Oberon] A C++ version of the Lola-2 compiler and an Oberon to C++ compiler
Chris Burrows
chris at cfbsoftware.com
Fri Apr 19 01:05:27 CEST 2019
> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> rochus.keller at bluewin.ch
> Sent: Thursday, 18 April 2019 9:43 PM
> To: oberon at lists.inf.ethz.ch
> Subject: Re: [Oberon] A C++ version of the Lola-2 compiler and an
> Oberon to C++ compiler
>
> @ Chris Burrows
>
> Thank you very much for the implementation; it's obviously much more
> elegant than my quick approach. There is also this proposal by J rg
> Straube:
>
> int _MOD(int a, b) { int m = a%b; if (a<0) m += b; return m; }
> int _MOD(int a, b) { return a<0 ? a%b+b : a%b ; }
> int _MOD(int a, b) { return a & (b-1); }
>
None of those gives the same results as either your quick approach or my implementation, e.g.
a := -21
b := 7
The result of a MOD b should be 0. Unless I'm mistaken the first two return 7 and the last returns 2.
Regards,
Chris
Chris Burrows
CFB Software
http://www.astrobe.com
More information about the Oberon
mailing list