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

Réponses (2)

Jan
Jan le 8 Mar 2021
Modifié(e) : Jan le 8 Mar 2021

0 votes

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 le 8 Mar 2021

0 votes

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)

Tags

Modifié(e) :

Jan
le 8 Mar 2021

Community Treasure Hunt

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

Start Hunting!

Translated by