Azzera filtri
Azzera filtri

covert 9.2532 decimal into binary

1 visualizzazione (ultimi 30 giorni)
Pratik Anandpara
Pratik Anandpara il 16 Mar 2017
Modificato: Roger Stafford il 16 Mar 2017
convert decimal into binary with decimal point

Risposte (1)

Roger Stafford
Roger Stafford il 16 Mar 2017
Modificato: Roger Stafford il 16 Mar 2017
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 Commenti
Pratik Anandpara
Pratik Anandpara il 16 Mar 2017
s=binstr(9.2532) i edit this in command window or function file
Roger Stafford
Roger Stafford il 16 Mar 2017
Change 'finite' to 'isfinite'.

Accedi per commentare.

Tag

Non è stata ancora inserito alcun tag.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by