% badFloat.m
% Illustrate bad floating point compare in MATLAB
% P. Conrad for CISC106 section 99 11/06/2006

length = 10;
width = 30;
price = 100;

pricePerSquareInch = price / (length * width);

expectedAnswer = 0.33333

if (pricePerSquareInch == expectedAnswer)
  fprintf('It worked\n');
else
  fprintf('It didn''t work\n');
end

