Problem 44971. Convert base 10 to base x (2-16)
The exact solution for 38.59 in base 15 is the repeating decimal 28.8cb3b3b3b3b3b3b3..., which means the given solution 28.8cb3b3b3b3b42d4a contains some "junk digits" at the end; it's not really fair to ask for those junk digits as opposed to any others. Also, it looks like trailing zeros are supposed to be removed, but some of the base 2 solutions contain a trailing zero.
You are correct. Thanks for the comment. Fixed the errors you detected as well as a few others. Should be good now.
Hi David, nice problem but there are still I believe a few precision issues remaining in the testsuite. For example the number "7285.4" as a float can only be precisely encoded up to ~1e-12 (since eps(7285.4)=9.0949e-13), so its base-15 representation cannot be defined with 16-decimal places (as that would require >1e-19 precision). I believe perhaps you could fix that simply entering the input decimal numbers using chars, which would avoid any limited-precision issues? (or by relaxing the requirements to fewer decimal places)
Changed and fixed the problem. Input is now cell array of character arrays.
It seems the precision issues were indeed fixed. :)
Not sure what the problem was, but I changed #6 and added some additional test problems.
Oh, the problem was with my algorithm, sorry. I am indeed using python's long int (for multiplication of large integers), but I was relying on str2num for some operations (which apparently introduced floats back in my code). After removing it, it worked out fine.
PS: This new update knocked out some wrong solutions (including some of mine). Awesome. :)
In each of test3, test4 and test5, there is a number with a decimal fractional part 0.0962. It appears as thought it was converted in each case as though the fractional part was 0.962.
Corrected tests 3,4,5. Answers should all be good now.
Solution CommentsShow comments
Problem Recent Solvers2
Back to basics 17 - white space
Rotate and display numbered tile
Sort numbers by outside digits
More from this Author50
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!