Cody

Problem 2046. Convert binary numbers to hexadecimal numbers

Solution 3349758

Submitted on 23 Oct 2020 by Akrem Hadji
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = [1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1] ; y_correct = 'F0 E1'; assert(isequal(bin2hex(x),y_correct));

o = 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 1 y = 'F0 E1'

2   Pass
x = ones(1,80); y_correct = 'FF FF FF FF FF FF FF FF FF FF'; assert(isequal(bin2hex(x),y_correct));

o = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 58 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 59 through 80 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 y = 'FF FF FF FF FF FF FF FF FF FF'

3   Pass
x = zeros(1,8); y_correct = '00'; assert(isequal(bin2hex(x),y_correct));

o = 0 0 0 0 0 0 0 0 y = '00'

4   Pass
x = '1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 0 1 0'; y_correct = '9E 6B E2 9A'; assert(isequal(bin2hex(x),y_correct));

v = 1 v = 1 0 v = 1 0 0 v = 1 0 0 1 v = 1 0 0 1 1 v = 1 0 0 1 1 1 v = 1 0 0 1 1 1 1 v = 1 0 0 1 1 1 1 0 v = 1 0 0 1 1 1 1 0 0 v = 1 0 0 1 1 1 1 0 0 1 v = 1 0 0 1 1 1 1 0 0 1 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 v = 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 v = Columns 1 through 29 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 Column 30 0 v = Columns 1 through 29 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 Columns 30 through 31 0 1 v = Columns 1 through 29 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 Columns 30 through 32 0 1 0 o = Columns 1 through 29 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 1 Columns 30 through 32 0 1 0 y = '9E 6B E2 9A'

Suggested Problems

Community Treasure Hunt

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

Start Hunting!