Guest User

Untitled

a guest
Jun 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.29 KB | None | 0 0
  1. function s = binstr(x)
  2.  
  3. if ~finite(x)|(length(x)~=1), error('x must be a finite scalar.'), end
  4. b = (x<0); x = abs(x);
  5. s = zeros(1,53);
  6. [f,e] = log2(x);
  7. for i = 1:53
  8. f = 2*f;
  9. d = floor(f);
  10. f = f - d;
  11. s(i) = d+48;
  12. end
  13. s = ['0.' s sprintf('*2^(%d)',e)];
  14. if b, s = ['-' s]; end
  15. s = setstr(s);
Add Comment
Please, Sign In to add comment