Converting decimals to sexagesimal (base sixty) in javascript
<p>What is the best way to convert decimal numbers (base ten) to sexagesimal (base sixty) represented as a string using 0-9, A-Z and a-x as the digits.</p>

<p>I'm planning to code it in javascript but any help is appreciated.</p>

<p>Usage Example:</p>

<pre><code>&gt;&gt;decToSex(60);
"10"
&gt;&gt;decToSex(123);
"23"
&gt;&gt;decToSex(1000000);
"4bke"
&gt;&gt;decToSex(1234567.89);
"5gu7.rO"
</code></pre>

<p>The final code I used, based on Paolo's answer:</p>

<pre><code>var decToSex = function(){
    var decToSexMap = ['0','1','2','3','4','5','6','7','8','9',
      'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
      'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x'];

    return function(number){

     var negative = '';
     if (number &lt; 0){
      var negative = '-';
     }

     number = number.toString().split('.');
     var integer = Math.abs(number[0]);
     var fraction = number[1];
     var result = '';

     do {
      result = decToSexMap[integer % 60] + result;
      integer = parseInt(integer / 60);
     } while (integer &gt; 0);

     if (fraction){
      var decimalPlaces = fraction.toString().length;
      result += '.';
      fraction = parseFloat('.' + fraction);

      var x = 0;
      do {
       x++;
       var res = (fraction * 60).toString().split('.');
       result = result + decToSexMap[res[0]];

       if (res[1]) {
        fraction = parseFloat('.' + res[1]);
       }
       else {
        break;
       }
      } while (x &lt; decimalPlaces);
     }
     return negative + result;
    }
}();
</code></pre>
