Cody

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

Solution 1960093

Submitted on 4 Oct 2019 by William
• Size: 112
• This is the leading solution.
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.1f9a6b50b','2694.fcd35a8588'}; assert(isequal(dec2basex(dec,x),y_correct))

2   Pass
dec = [12345.12345,9876.9876]; x = 7; y_correct={'50664.0602255245326442','40536.6625141031624663'}; 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.0010011010001011','1011111001101011011.0111110100001011','1110010001101010011000000001110001001001.00011000101','1111.0010011101001010','1011010000100000111011.0101011010011111','110011001','10100010110111110011.1100111010010111','111011011010101.1000000111001010','1110001110101.0110011001100110','100110.1001011100001010'}; 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.23d2328955460e16','7a839.74d822b72acb9542','1a7bbad1da6.1699a53843c6d265','10.24804853517ecc5e','3d4687.51202701347ad6c6','1c4','d29ed.c18959596b861b57','9031.7911d1d1d2a6d883','225a.5eeeeeeeeebcbea1','28.8cb3b3b3b3b42d4a'}; 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.1982083a8431a88a','169823.5a407946253a4420','13a16b470949.11a276','13.1a12871b92951307','ba3a77.40886226776a669','2a1','282097.9825b510827439','15731.610119a7a57a6104','4271.49724972496b1a61','32.70b62a68781b0a18'}; assert(isequal(dec2basex(dec,x),y_correct))

6   Pass
dec=0.173; x=11; y_correct={'0.19a2990645a78076'}; assert(isequal(dec2basex(dec,x),y_correct))

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

### Community Treasure Hunt

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

Start Hunting!