home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_std / real_ref.e < prev    next >
Text File  |  1999-06-05  |  2KB  |  104 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://SmallEiffel.loria.fr
  11. --
  12. class REAL_REF
  13.  
  14. inherit
  15.    HASHABLE;
  16.    NUMERIC
  17.       undefine out_in_tagged_out_memory, fill_tagged_out_memory
  18.       redefine
  19.          infix "^", prefix "+", prefix "-"
  20.       end;
  21.    COMPARABLE
  22.       redefine
  23.          out_in_tagged_out_memory, fill_tagged_out_memory
  24.       end;
  25.  
  26. feature 
  27.  
  28.    item: REAL;
  29.  
  30. feature
  31.    
  32.    set_item(value: like item) is
  33.       do
  34.          item := value;
  35.       end;
  36.  
  37.    infix "+" (other: like Current): like Current is
  38.       do
  39.          Result := item + other.item;
  40.       end;
  41.  
  42.    infix "-" (other: like Current): like Current is
  43.       do
  44.          Result := item - other.item;
  45.       end;
  46.  
  47.    infix "*" (other: like Current): like Current is
  48.       do
  49.          Result := item * other.item;
  50.       end;
  51.  
  52.    infix "/" (other: like Current): like Current is
  53.       do
  54.          Result := item / other.item;
  55.       end;
  56.  
  57.    infix "^" (exp: INTEGER): DOUBLE_REF is
  58.       do
  59.          Result := item ^ exp;
  60.       end;
  61.  
  62.    prefix "+" : like Current is
  63.       do
  64.          Result := item;
  65.       end;
  66.  
  67.    prefix "-" : like Current is
  68.       do
  69.          Result := -item;
  70.       end;
  71.  
  72.    infix "<" (other: like Current): BOOLEAN is
  73.       do
  74.          Result := item < other.item
  75.       end;
  76.  
  77.    divisible (other: like Current): BOOLEAN is
  78.       do
  79.          Result := (other.item /= 0.0)
  80.       end;
  81.  
  82.    one: like Current is
  83.       do
  84.          Result := 1.0;
  85.       end;
  86.  
  87.    zero: like Current is
  88.       do
  89.          Result := 0.0;
  90.       end;
  91.  
  92.    out_in_tagged_out_memory, fill_tagged_out_memory is
  93.       do
  94.          item.fill_tagged_out_memory;
  95.       end;
  96.  
  97.    hash_code: INTEGER is
  98.       do
  99.          Result := item.hash_code;
  100.       end;
  101.  
  102. end -- REAL_REF
  103.  
  104.