covert 9.2532 decimal into binary
조회 수: 1 (최근 30일)
이전 댓글 표시
convert decimal into binary with decimal point
댓글 수: 0
답변 (1개)
Roger Stafford
2017년 3월 16일
편집: Roger Stafford
2017년 3월 16일
function s = binstr(x)
if ~isfinite(x)|(length(x)~=1), error('x must be a finite scalar.'),end
b = (x<0); x = abs(x);
s = zeros(1,53);
[f,e] = log2(x);
for i = 1:53
f = 2*f;
d = floor(f);
f = f - d;
s(i) = d+48;
end
s = ['0.' s sprintf('*2^(%d)',e)];
if b, s = ['-' s]; end
s = char(s);
return
댓글 수: 9
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!