cyfile / Matlab-base-toolbox

本人使用Matlab基础工具箱所编写的各种代码
1 stars 0 forks source link

hex dec num #6

Open 213cy opened 8 years ago

213cy commented 8 years ago
hex2num('4000000000000000')
hex2num('4008000000000000')
hex2num('c008000000000000')

sprintf('%bx',-3)
sprintf('%bx',-3)
bitget(bitset(0,2),8:-1:1)

hex2dec('4e00')
double('一')
char(hex2dec('9fff'))
char('一'+(-2:1:3))
dec2hex(double('曙光'))

%% %%%%%%%%%%%%%%%%%
hex2num('ffff ffff ffff ffff')
hex2num('ffffffff ffff ffff')
hex2num('ffffffff ffffffff')

num2hex(eps(1))

%%
% realmin returns the smallest positive normalized floating-point number in IEEE double precision.
% 注意是  normalized .需要知道浮点数结构 才知道 realmin 的值得含义
num2hex(eps(0))
num2hex(realmin)

%%

num2hex(realmax)
hex2num('7ffffffffffffff')
num2hex(nan)

num2hex(-nan)
num2hex(inf)
num2hex(-inf)

flintmax
num2hex(flintmax)
eps(flintmax)
eps(flintmax-1)
(flintmax+1)==(flintmax+eps)
(flintmax-1)==(flintmax+eps)

dec2hex(16)

%% 如何从b=num2hex(single(-320)) 算出 -320 :
a=-320;
num2hex(a)
b=single(-320)
num2hex(b)
%% 如何从b=num2hex(single(-320)) 算出 -320 :
typecast(uint32(hex2dec(num2hex(single(-320)))),'single')

%% % http://cn.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html#bqxyrhp

213cy commented 3 years ago

intmax('int64') intmin
realmax('single') realmin