/usr/share/freemat/toolbox/binary/dec2bin.m is in freemat-data 4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | % DEC2BIN DEC2BIN Convert Decimal to Binary String
%
% Usage
%
% Converts an integer to a binary string. The syntax for its
% use is
%
% y = dec2bin(x,n)
%
% where x is the positive integer, and n is the number of
% bits to use in the representation. Alternately, if you leave
% n unspecified,
%
% y = dec2bin(x)
%
% the minimum number of bits needed to represent x are used.
% If x is a vector, then the resulting y is a character
% matrix.
% Copyright (c) 2002-2006 Samit Basu
% Licensed under the GPL
function t = dec2bin(x,n)
x = x(:);
if (size(x) == [0,0])
t = string([]);
return;
end
if (~exist('n') && max(x) > 0)
n = ceil(log2(max(x)+1e-10));
elseif (~exist('n'))
t = string(zeros(size(x))+'0');
return;
elseif (max(x) == 0)
t = string(zeros(size(x))+'0');
return;
end
n = max(1,n);
t = string(int2bin(x,n)+'0');
|