function xmax = realmax
%REALMAX Largest positive floating point number.
%	x = realmax is the largest floating point number representable
%	on this computer.  Anything larger overflows.
%
%	See also EPS, REALMIN, POW2.

%	C. Moler, 7-26-91, 6-10-92.
%	Copyright (c) 1984-93 by The MathWorks, Inc.

% Most computers have IEEE floating point arithmetic,
% but there are a few important exceptions.

comp = computer;

if isieee
   maxexp = 1023;
elseif strcmp(comp,'CRAY')
   maxexp = 8189;
elseif strcmp(comp(1:3),'VAX')
   % Check if D or G floating point
   if comp(7) == 'D',
      maxexp = 126;
   else
      maxexp = 1022;
   end
else
   error('Unknown computer type.')
end

% pow2(f,e) is f*2^e, computed by adding e to the exponent of f.
% 2-eps is the largest floating point number smaller than 2.

xmax = pow2(2-eps,maxexp);
