flplot.m

来自「SFLOP simulates a floating point operat」· M 代码 · 共 44 行

M
44
字号
       %%  PURPOSE:%  FLPLOT  plots all positive floating point numbers for %  a given base, exponent range and mantissa length%%%  Matthias Heinkenschloss%  Department of Computational and Applied Mathematics%  Rice University%  Feb 12, 2002%%disp('  Plot of all positive floating point numbers                 ')disp('             0       -1      -2            -(t-1)   e         ')disp('  x = ( d * b + d * b + d * b +..... d   * b  )  * b  ,       ')disp('         0       1       2            (t-1)                   ')disp('                                                              ')disp('  where   b =2  is the base and  e  in [ e_min, e_max ] is the exponent. ')b = 2;t     = input(' Mantissa length t = ');e_min = input(' lower boundary of exponent range e_min = ');e_max = input(' upper boundary of exponent range e_max = ');x = [0];k = 1;for e = e_min:e_max    k = k+1;    x = [x, b^e];    while( x(k) < b^(e+1)*(1-b^(-t)) )        k = k+1;        x = [x, x(k-1) + b^(e-(t-1))];    endend    disp(x')        plot(x,zeros(size(x)),'r+' )title(['positive floating point numbers (\beta = 2, t=',int2str(t),...       ' e_{min} =', int2str(e_min),' e_{max} =', int2str(e_max),')'])

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?