Quote (carteblanche @ Sep 13 2015 03:19pm)
i assume "positive number" means a 32 bit integer?
start with pseudo code to get your logic down, then convert the syntax to matlab.
Why the assumption? There's nothing special about the fractions, just keep iterating over the remainder until you either get an exact result or get to some maximum string length that you decide upon.
rough pseudo code:
result = "1232" //whatever whole part in string format
remainder = 0.123 //whatever the decimal fraction was
maxSteps = 20 //max fraction length in base 12 to approximate the fraction in base 10
for (int step = 0; step < maxSteps AND remainder != 0; step++) {
nextDigit = remainder * 12
result += nextDigit.toInteger().toString()
remainder = nextDigit - nextDigit.toInteger()
}
This post was edited by russian on Sep 18 2015 03:15pm