Re.[Oberon] Native 24.08.2002: Compiler Bug
Stefan Salewski wrote:
I think there is something wrong with the DIV statement.
Yes, it's the same with n-o alpha 2001. Also using constants: 10 DIV 3 = 3 - 10 DIV 3 = - 3 // DIV has precendence over "-" -(-10 DIV 3) = 3 (-10) DIV 3 = - 4 // truncates toward minus-infinity ?! -((-10) DIV 3) = 4 Besides this, looking into DIV raised other issues for me. Desktops.OpenDoc Oberon.Report.Text ~ shows: They are related by the following formulas defined for any x and positive divisors y: x = (x DIV y) * y + (x MOD y) 0 <= (x MOD y) < y Examples: x y x DIV y x MOD y 5 3 1 2 -5 3 -2 1 ====== I would expect DIV to 'truncate towards zero'. Not towards minus infinity ? And when I try to analyse the 'rules' further I'm confused: * From Oberon.Report.Text operator DIV: first operand = integer ; second operand = integer result type = smallest integer type including both operands So here Oberon.Report.Text DIV defines the 2 operands 'symetically', but elsewhere "positive divisors y" (x may not be positive). * Then let's see the definition/syntax of "integer":- integer = digit {digit} | digit {hexDigit} "H". real = digit {digit} "." {digit} [ScaleFactor]. ScaleFactor = ("E" | "D") ["+" | "-"] digit {digit}. It seems to me, that from the above "-10" would fail the syntax of an integer ? ! Where is my reasoning wrong ? Apparently "integer" is not type INTEGER ? So my queries are: 1. is -10 a n-o 'integer' ? 2. are the valid two operands of DIV of the same type ? 3. are these claims of mine of inconsistency in Oberon.Report.Text valid ? -- Chris Glur.
participants (1)
-
eas-lab@absamail.co.za