home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / ELMAT.DI$ / REALMAX.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  866 b   |  35 lines

  1. function xmax = realmax
  2. %REALMAX Largest positive floating point number.
  3. %    x = realmax is the largest floating point number representable
  4. %    on this computer.  Anything larger overflows.
  5. %
  6. %    See also EPS, REALMIN, POW2.
  7.  
  8. %    C. Moler, 7-26-91, 6-10-92.
  9. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  10.  
  11. % Most computers have IEEE floating point arithmetic,
  12. % but there are a few important exceptions.
  13.  
  14. comp = computer;
  15.  
  16. if isieee
  17.    maxexp = 1023;
  18. elseif strcmp(comp,'CRAY')
  19.    maxexp = 8189;
  20. elseif strcmp(comp(1:3),'VAX')
  21.    % Check if D or G floating point
  22.    if comp(7) == 'D',
  23.       maxexp = 126;
  24.    else
  25.       maxexp = 1022;
  26.    end
  27. else
  28.    error('Unknown computer type.')
  29. end
  30.  
  31. % pow2(f,e) is f*2^e, computed by adding e to the exponent of f.
  32. % 2-eps is the largest floating point number smaller than 2.
  33.  
  34. xmax = pow2(2-eps,maxexp);
  35.