float to binary ?

조회 수: 12 (최근 30일)
reta jon
reta jon 2021년 3월 8일
편집: Jan 2021년 3월 8일
Hi,
Why does this function round and how do you return the same number without rounding
A=0.569546;
B = float2bin(A)
C=bin2float(B)
result: c= 0.5695

답변 (2개)

Jan
Jan 2021년 3월 8일
편집: Jan 2021년 3월 8일
Are you sure that there is a rounding? Or is it the display in the command window only?
A = 0.569546;
B = float2bin(A)
C = bin2float(B)
A - C
format long g % Adjust the format of the display
C
float2bin and bin2float are no commands of Matlab's toolboxes. So maybe it would help to mention, where you ot these functions from.

the cyclist
the cyclist 2021년 3월 8일
Assuming that you are using this File Exchange entry, it doesn't round. The issue is that the default MATLAB display format only shows the first 4 figures. Try this instead:
format long
A=0.569546;
B = float2bin(A)
C=bin2float(B)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by