float to binary ?
조회 수: 12 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
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.
댓글 수: 0
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!