in reply to Re: Base20 Blues
in thread Base20 Blues

Thanks for your help to all. I really like the simplicity of ikegami's reply, but while it gives the answers, how would I make it so that it returns something when the result is zero, because the maya had a zero place holder. The others are also great, and I will learn from them; I just would rather not have to use a cpan module for such a simple task, and I need the results by number so I can output a symbol gif for each. Again, thanks to you pros.

Replies are listed 'Best First'.
Re^3: Base20 Blues
by ikegami (Patriarch) on Jan 10, 2011 at 15:47 UTC

    how would I make it so that it returns something when the result is zero

    It currently puts 0 in @digits. Adjust the last line as desired.

    @digits = 0 if !@digits;

    I just would rather not have to use a cpan module for such a simple task

    Well, it was complex enough that you wanted help with it. I'm also convinced mine can give the wrong result due to floating point error.

    my @digits; do { unshift @digits, $num % 20; $num = ( $num - ( $num % 20 ) ) / 20; } while $num > 0;