Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = [0, -1, 0.5, 2.25, 10.125, -10.5];
s = {'0', '-1', '0.1', '10.01', '1010.001', '-1010.1'};
for n=1:length(x);
assert(strcmpi(s{n}, float2base(x(n), 2)));
end
|
2 | Pass |
x = [0, 1, 0.5, 2.25, 10.125];
s = {'0', '1', '0.8', '2.4', 'a.2'};
for n=1:length(x);
assert(strcmpi(s{n}, float2base(x(n), 16)));
end
|
3 | Pass |
% only checking 6 digits after period
x = 3.14;
s = {'11.0010001111','3.10753412172','3.23d70a3d70a'};
bases = [2,8,16];
for n=1:length(bases)
assert(strncmpi(s{n}, float2base(x, bases(n)), 8));
end
|
Remove the small words from a list of words.
672 Solvers
137 Solvers
746 Solvers
401 Solvers
273 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!