www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SinglePrecisionMachineEpsilonExample.m

    %% Accuracy in Single Precision
% Display the distance from |1.0| to the next largest single-precision
% number.

% Copyright 2015 The MathWorks, Inc.

d = eps('single')

%% 
% |eps('single')| is equivalent to |eps(single(1.0))|.

%%
% Compute |log2(eps('single'))|.  
d = log2(eps('single'))

%%
% In base |2|, single-precision |eps| is equal to |2^-23|.

%%
% Find the distance from the single-precision representation of 10.0 to
% the next largest single-precision number.
d = eps(single(10.0))