[Oberon] Assumed issue in the Lola-2 compiler
rochus.keller at bluewin.ch
rochus.keller at bluewin.ch
Mon Apr 15 14:35:06 CEST 2019
Ok, I think I found a decent solution.
After reading the response of Chris Burrows I have to correct my last post.
>> Assuming standard mathematics this specification is complete
That was wrong. Since we don't have two equations but only one equation and a relation the specification is under-determined.
@ Chris Burrows:
Thank you very much for your explications. But I think the step where you enter r=15 into 'q = -(r + 1) / 16' is arbitrary.
You could as well enter r=0 which also satisfies the relation, so
r = 0 -> q = -( 0 + 1 ) / 16 = -1 / 16 = 0
r = 15 -> q = -( 15 + 1 ) / 16 = -16 / 16 = -1
This is undecidable from my point of view; correct me if I'm wrong.
But I can avoid this indetermination by using the following two functions and re-using features of the C language:
int MOD(int a, int b) { return ( a % b + b ) % b; }
int DIV(int a, int b) { return ( a - MOD( a, b) ) / b; }
DIV(-1,16) gives -1 so the behavoir seems the same as the Oberon implementations. Jörg pointed out how MOD can still be simplified, but for now I will change the Generator and do some tests.
Best
R.K.
More information about the Oberon
mailing list