Example #1
0
 /**
  * Convert a number to a string, using the given alphabet.
  *
  * @param \Moontoast\Math\BigNumber $number
  * @param number $padToLength
  * @return string
  */
 private function numToString($number, $padToLength = null)
 {
     $output = '';
     while ($number->compareTo('0') > 0) {
         $ret = self::divmod($number, $this->alphabetLength);
         $number = $ret[0];
         $digit = $ret[1];
         $output .= $this->alphabet[(int) $digit->getValue()];
     }
     if (!is_null($padToLength)) {
         $reminder = max($padToLength - strlen($output), 0);
         $output = $output . str_repeat($this->alphabet[0], $reminder);
     }
     return $output;
 }