Cody

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

Solution 3381628

Submitted on 25 Oct 2020 by Rafael S.T. Vieira
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
dec = {'12345.12345','9876.9876'}; x = 16; y_correct={'3039.1f9a6b50b0f27bb2fec56d5cfaacd9e83e425aee631f8a0902','2694.fcd35a858793dd97f62b6ae7d566cf41f212d77318fc504816'}; assert(isequal(dec2basex(dec,x),y_correct))

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

3   Pass
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))

4   Pass
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))

5   Pass
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))

6   Pass
dec={'0.17376528735490000123665384983467234528473629840'}; x=11; y_correct={'0.1a031089610477366500071327656074030289855640995355'}; assert(isequal(dec2basex(dec,x),y_correct))

7   Pass
dec={'0'}; x=3; y_correct={'0'}; 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!