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