bin2flt.m

来自「这是《Numerical Methods with MATLAB: Imple」· M 代码 · 共 16 行

M
16
字号
function f = bin2flt(c)
% bin2flt  Expand a binary representation of floating point mantissa
%
% Synopsis:  f = bin2flt(c)
%
% Input:     c = (string) bit sequence of the fractional part of a normalized
%                floating point number.
%
% Output     f = numerical equivalent of the bit pattern
%                      f = sum(k=1:n){ c(k)*2^(-k) }

f=0;
for k=1:length(c)
  f = f + str2num(c(k))*2^(-k);
end

⌨️ 快捷键说明

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