  function fpFacts()
% Take a look at precision, underflow, and overflow in the IEEE standard
% for double precision floating point arithmetic.

% The IEEE double format stores numbers in the form
%
%          1.b_1 b_2 ... b_t  x (some power of 2)
% 
% where b_1,...,b_t  are bits. Here is code to figure out t:
x = 1;
k = 0;
while 1+x>1
    % The mantissa is long enough to store 1+1/2^k 
    x = x/2;
    k = k+1;
end
fprintf('The number of bits dedicated to the mantissa = t = %1d\n',k-1)
fprintf('\nThe distance from 1 to the next largest floating point number is 1/2^%1d.\n',k-1)

% Let's look at underflow...
x = 1;
k = 0;
while x > 0
    x = x/2;
    k = k+1;
end
fprintf('\nThe smallest integer k so fl(1/2^k) is zero is %1d.\n',k)

% Let's look at overflow...
x = 1;
k = 0;
while x < inf
    x = 2*x;
    k = k+1;
end
fprintf('\nThe smallest integer k so fl(2^k) == inf  is %1d.\n',k)