home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_std / double_ref.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  114 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 DOUBLE_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: DOUBLE;
  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;
  40.          Result.set_item(item + other.item);
  41.       end;
  42.  
  43.    infix "-" (other: like Current): like Current is
  44.       do
  45.          !!Result;
  46.          Result.set_item(item - other.item);
  47.       end;
  48.  
  49.    infix "*" (other: like Current): like Current is
  50.       do
  51.          !!Result;
  52.          Result.set_item(item * other.item);
  53.       end;
  54.  
  55.    infix "/" (other: like Current): like Current is
  56.       do
  57.          !!Result;
  58.          Result.set_item(item / other.item);
  59.       end;
  60.  
  61.    infix "^" (exp: INTEGER): like Current is
  62.       do
  63.          !!Result;
  64.          Result.set_item(item ^ exp);
  65.       end;
  66.  
  67.    prefix "+" : like Current is
  68.       do
  69.          !!Result;
  70.          Result.set_item(item);
  71.       end;
  72.  
  73.    prefix "-" : like Current is
  74.       do
  75.          !!Result;
  76.          Result.set_item(-item);
  77.       end;
  78.  
  79.    infix "<" (other: like Current): BOOLEAN is
  80.       do
  81.          Result := item < other.item
  82.       end;
  83.  
  84.    divisible (other: like Current): BOOLEAN is
  85.       do
  86.          Result := (other.item /= 0.0)
  87.       end;
  88.  
  89.    one: like Current is
  90.       do
  91.          !!Result;
  92.          Result.set_item(1.0);
  93.       end;
  94.  
  95.    zero: like Current is
  96.       do
  97.          !!Result;
  98.          Result.set_item(0.0);
  99.       end;
  100.  
  101.    out_in_tagged_out_memory, fill_tagged_out_memory is
  102.       do
  103.          tagged_out_memory.append("item: "); 
  104.          item.fill_tagged_out_memory;
  105.       end;
  106.  
  107.    hash_code: INTEGER is
  108.       do
  109.          Result := item.hash_code;
  110.       end;
  111.  
  112. end -- DOUBLE_REF
  113.  
  114.