Table of Contents
Previous Chapter
- indexing
- description: "Objects to which numerical operations are applicable";
- note: "The model is that of a commutative ring."
- deferred class interface
- feature -- Access
- -- Neutral element for "*" and "/"
- Result_exists: Result /= Void
- -- Neutral element for "+" and "--"
- Result_exists: Result /= Void
- feature -- Status report
- divisible (other: like Current): BOOLEAN
- -- May current object be divided by other?
- other_exists: other /= Void
- exponentiable (other: NUMERIC): BOOLEAN
- -- May current object be elevated to the power other?
- other_exists: other /= Void
- feature -- Basic operations
- infix "+" (other: like Current): like Current
- -- Sum with other (commutative).
- other_exists: other /= Void
- result_exists: Result /= Void;
- commutative: equal (Result, other + Current)
- infix "--" (other: like Current): like Current
- -- Result of subtracting other
- other_exists: other /= Void
- result_exists: Result /= Void
- infix "*" (other: like Current): like Current
- -- Product by other
- other_exists: other /= Void
- result_exists: Result /= Void
- infix "/" (other: like Current): like Current
- -- Division by other
- other_exists: other /= Void;
- good_divisor: divisible (other)
- result_exists: Result /= Void
- infix "^" (other: NUMERIC): NUMERIC
- -- Current object to the power other
- other_exists: other /= Void;
- good_exponent: exponentiable (other)
- result_exists: Result /= Void
- -- Unary plus
- result_exists: Result /= Void
- prefix "--": like Current
- -- Unary minus
- result_exists: Result /= Void
- invariant
- neutral_addition: equal (Current + zero, Current);
- self_subtraction: equal (Current -- Current, zero);
- neutral_multiplication: equal (Current * one, Current);
- self_division: divisible (Current) implies equal (Current / Current, one)
- end
Table of Contents
Next Chapter
|