| 123456789101112131415161718192021222324252627282930 |
- MODULE Showcase2;
- // Stage 1.7 tour: scalar TYPEs used for real work — subranges with
- // decimal and hex bounds, aliases, folded CONSTs, all operators.
- // Expected ExitCode: 71 (hand-computed, truncating DIV).
- IMPORT Dummy;
- FROM Elsewhere IMPORT Thing;
- CONST
- Step = 7;
- Bonus = -5;
- TYPE
- Score = [0..100];
- Nibble = [0x0..0xF];
- Amount = INTEGER;
- VAR
- ExitCode : INTEGER;
- s : Score;
- i : Nibble;
- a : Amount;
- BEGIN
- s := 90;
- i := 0xB; (* 11 *)
- (* (90 + 11) * 7 DIV 10 + (-5) = 707 DIV 10 - 5 = 70 - 5 = 65 *)
- a := (s + i) * Step DIV 10 + Bonus;
- (* 65 + 90 MOD 7 = 65 + 6 = 71 *)
- ExitCode := a + s MOD Step
- END Showcase2.
|