% epsilonExample.m
% Written by John Bell for CS 109 Fall 2009

% This is a short example using a while loop to calculate "epsilon",
% the smallest value that can be added to 1 and still have the result
% be distinguished from 1.  Results may differ from machine to machine.

epsilon = 1; % Set a single binary bit
while( 1 + epsilon > 1 )
    disp( [ 'epsilon = ', num2str( epsilon ) ] );
    epsilon = epsilon / 2; % Shift the bit by one position and try again.
end