PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/lib/numeric/numeric.e

http://github.com/tybor/Liberty
Specman e | 91 lines | 43 code | 12 blank | 36 comment | 0 complexity | 94e1f96df9a0a18d5358a2f11187cad4 MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4deferred class NUMERIC
 5   --
 6   -- This class describes a ring.
 7   --
 8
 9inherit
10   HASHABLE -- *** Here ? Weird ! *** 3th feb 2006 *** Fred + Guillem + Dom ***
11
12feature {ANY}
13   infix "+" (other: like Current): like Current
14         -- Sum with `other' (commutative).
15      deferred
16      end
17
18   infix "-" (other: like Current): like Current
19         -- Result of subtracting `other'.
20      deferred
21      end
22
23   infix "*" (other: like Current): like Current
24         -- Product by `other'.
25      deferred
26      end
27
28   infix "/" (other: like Current): NUMERIC
29         -- Division by `other'.
30      require
31         other /= Void
32         other /= zero
33         divisible(other)
34      deferred
35      end
36
37   prefix "+": like Current
38         -- Unary plus of `Current'.
39      deferred
40      end
41
42   prefix "-": like Current
43         -- Unary minus of `Current'.
44      deferred
45      end
46
47   divisible (other: like Current): BOOLEAN
48         -- May `Current' be divided by `other' ?
49      require
50         other /= Void
51      deferred
52      end
53
54   one: like Current
55         -- Neutral element for "*" and "/".
56      deferred
57      end
58
59   zero: like Current
60         -- Neutral element for "+" and "-".
61      deferred
62      end
63
64   sign: INTEGER_8
65         -- Sign of Current (0 -1 or 1).
66      deferred
67      ensure
68         Result.in_range(-1, 1)
69      end
70
71end -- class NUMERIC
72--
73-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
74--
75-- Permission is hereby granted, free of charge, to any person obtaining a copy
76-- of this software and associated documentation files (the "Software"), to deal
77-- in the Software without restriction, including without limitation the rights
78-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
79-- copies of the Software, and to permit persons to whom the Software is
80-- furnished to do so, subject to the following conditions:
81--
82-- The above copyright notice and this permission notice shall be included in
83-- all copies or substantial portions of the Software.
84--
85-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
89-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
90-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
91-- THE SOFTWARE.