% MATLAB script file: demowhile

% Uses while statement to compute approximation to machine epsilon.

% Loop initialization.
myeps = 1.0

% Loop while addition of myeps to 1 is returns a floating point
% number distinct from 1.
while (1 + myeps) ~= 1 
   myeps = myeps / 2
end
% Multiply by 2 to recover last value for which loop condition was true.
myeps = 2 * myeps
fprintf('demowhile: Estimated value of machine epsilon: %.16e\n', myeps);
fprintf('demowhile: myeps - eps: %.16e\n', myeps - eps);
