Cody

Problem 44971. Convert base 10 to base x (2-16)

Solution 1960093

Submitted on 4 Oct 2019
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   Fail
dec = {'12345.12345','9876.9876'}; x = 16; y_correct={'3039.1f9a6b50b0f27bb2fec56d5cfaacd9e83e425aee631f8a0902','2694.fcd35a858793dd97f62b6ae7d566cf41f212d77318fc504816'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test1 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

2   Fail
dec = {'12345.12345','9876.9876'}; x = 7; y_correct={'50664.06022552453265131463344354240404235443346315126532','40536.66251410316246446430121226644446623210142466425160'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test2 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

3   Fail
dec= {'9626.150562201365','389979.4884571975','981037227081.0962','15.15348748187026','2951227.338373619','409','667123.807','30421.507','7285.4','38.59'}; x=2; y_correct={'10010110011010.00100110100010110011111010010010111000000101111001','1011111001101011011.01111101000010111000011111101000110000100010000011','1110010001101010011000000001110001001001.11110110010001011010000111001010110000001000001100','1111.00100111010010101111010010100010111110100110100010','1011010000100000111011.01010110100111111010011101001011011011110010010101','110011001','10100010110111110011.11001110100101111000110101001111110111110011101101','111011011010101.10000001110010101100000010000011000100100110111010','1110001110101.01100110011001100110011001100110011001100110011001','100110.10010111000010100011110101110000101000111101011100'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test3 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

4   Fail
dec= {'9626.150562201365','389979.4884571975','981037227081.0962','15.15348748187026','2951227.338373619','409','667123.807','30421.507','7285.4','38.59'}; x=15; y_correct={'2cbb.23d232895574925b61a330ea0041be888dd05d272c6debb5bb','7a839.74d822b72be7b37e4a15d19c6833eeba86521cd8a4703b06c2','1a7bbad1da6.e66b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b','10.24804853517eded1d80c4eb03ddaa58d94b90b6bea97624a51','3d4687.51202700d38291a0aebdccdbeb0a192837465564738291a0ae','1c4','d29ed.c1895959595959595959595959595959595959595959595959','9031.7911d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1','225a.6','28.8cb3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test4 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

5   Fail
dec= {'9626.150562201365','389979.4884571975','981037227081.0962','15.15348748187026','2951227.338373619','409','667123.807','30421.507','7285.4','38.59'}; x=12; y_correct={'56a2.1982083a8434a7813216a8355826455b2348a92b48a31a2729','169823.5a4079462553752650550860855789769561babbb1a3b81970','13a16b470949.b6640473675a3320237938b1770119a7a5699606ab3b294a90','13.1a12871b9295139a05b037452a1601527044583908350b7b30','ba3a77.408862266b4baa39275b1b0b56502b76731b5518199a862397','2a1','282097.9825b5108092712b86640473675a3320237938b1770119a7a5','15731.610119a7a5699606ab3b294a903557b7485461889b9842830a','4271.49724972497249724972497249724972497249724972497249','32.70b62a68781b05915343a0b62a68781b05915343a0b62a6878'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test5 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

6   Fail
dec={'0.987654321','0.112233445566778899','0.999888777666555444333222111'}; x=11; y_correct={'0.a95627970787569834161929016a9663a0a174aa092a569392','0.126423438910a502a335aa01a4a20835684720a02399561849','0.aaa940a65612657657985a6594073947095026a94159818275'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test6 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

7   Fail
dec={'9988.1234567','99887766.1122334455','11223344.5566778899'}; x=4; y_correct={'2130010.01332122312323203320312213013100333123033311121113','11331002222112.01302323111030013300213102313300013322332111021132','222310010300.20322002130103032012312321333323010132302002011333'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test7 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

8   Fail
dec={'0'}; x=3; y_correct={'0'}; assert(isequal(dec2basex(dec,x),y_correct))

Undefined function 'fix' for input arguments of type 'cell'. Error in dec2basex>convert (line 9) ai = fix(a); Error in dec2basex (line 4) base = [base lower(convert(dec(j),x))]; Error in Test8 (line 4) assert(isequal(dec2basex(dec,x),y_correct))

Suggested Problems

More from this Author29

Community Treasure Hunt

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

Start Hunting!