The matlab function dec2base converts a positive integer number to a specified base. Extend it so that it works with non integers and negative numbers. For example 10.5 in base16 is 'a.8', and -4 is base2 is '-100'.
The tests are not case-sensitive and check the first 6 digits after the decimal point.
Solution Stats
Problem Comments
1 Comment
Solution Comments
Show comments
Loading...
Problem Recent Solvers24
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52727 Solvers
-
Determine whether a vector is monotonically increasing
22865 Solvers
-
Reverse the elements of an array
1113 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1261 Solvers
-
135 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
The problem actually considers 6 digits before and after the decimal point in the target base, which means 12 digits. Imho, when stating the number of digits after the decimal point, we must specify the base that we are referring to (since the digit 8 in base 10 is 4 digits in base 2, and the 2-digit number 15 in base 10 is only one digit F in base 16) .