@param string $number A positive, binary number.

@return string
359393
private function twosComplement(string $number) : string
    {
        $xor = \str_repeat("\xff", \strlen($number));

        $number = $number ^ $xor;

        for ($i = \strlen($number) - 1; $i >= 0; $i--) {
            $byte = \ord($number[$i]);

            if (++$byte !== 256) {
                $number[$i] = \chr($byte);
                break;
            }

            $number[$i] = \chr(0);
        }

        return $number;
    }
252644
public static function ordinal($number)
    {
        $test_c = abs($number) % 10;
        $ext = ((abs($number) % 100 < 21 && abs($number) % 100 > 4) ? 'th' : (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) ? 'th' : 'st' : 'nd' : 'rd' : 'th'));

        return $number . $ext;
    }
120155
public static function mod11Pre($number, $base = 9)
    {
        $checksum = 0;
        $factor = 2;
        foreach (str_split(strrev((string) $number)) as $d) {
            $checksum += $d * $factor;
            if (++$factor > $base) {
                $factor = 2;
            }
        }
        return $checksum;
    }
1261485
public function toRoman($number)
    {
        $number = (int)$number;
        $roman = '';
        foreach ($this->getRomanValues() as $romanValue => $numberValue) {
            $roman .= str_repeat($romanValue, floor($number / $numberValue));
            $number = $number % $numberValue;
        }
        foreach ($this->getRomanExceptions() as $replaceThis => $withThis) {
            $roman = str_replace($replaceThis, $withThis, $roman);
        }
        return $roman;
    }
1044321
private static function getNum125($number) {
		/** @var int $result */
		/** @var int $n100 */
		$n100 = $number % 100;
		/** @var int $n100 */
		$n10 = $number % 10;
		if (($n100 > 10) && ($n100 < 20)) {
			$result = self::NUMBER_FORM_5;
		}
		else if ($n10 === 1) {
			$result = self::NUMBER_FORM_1;
		}
		else if (($n10 >= 2) && ($n10 <= 4)) {
			$result = self::NUMBER_FORM_2;
		}
		else {
			$result = self::NUMBER_FORM_5;
		}
		return $result;
	}
412931
public function encode($number)
    {
        $number = (int)$number;

        $result = array();

        if (0 === $number)
        {
            $result[] = $this->dictionary[0];
        }

        while ($number > 0)
        {
            $result[] = $this->dictionary[($number % $this->radix)];
            $number = floor($number / $this->radix);
        }

        return implode('', array_reverse($result));
    }
262431
public function getUnpredictableInv($number) {
		$maskSize=count($this->masks0);
		for($i=$maskSize-1;$i>=0;$i--) {
			$init=$this->masks1[$i];
			$end=$this->masks0[$i];
			$tmp=$number[$end];
			$number=substr_replace($number,$number[$init],$end,1);
			$number=substr_replace($number,$tmp,$init,1);
		}
		return $number;
	}
294754
public static function spellNumber($number)
    {
        $a = new \NumberFormatter(Yii::$app->language, \NumberFormatter::SPELLOUT);

        return $a->format($number);
    }
984997
protected function toWords($number)
    {
        $ret = '';

        if ($number === 0) {
            return $this->zero;
        }

        if ($number < 0) {
            $ret = $this->minus . $this->wordSeparator;
        }

        $numberGroups = $this->splitNumber(abs($number));
        $sizeOfNumberGroups = count($numberGroups);

        foreach ($numberGroups as $i => $numb) {
            $power = $sizeOfNumberGroups - $i;

            if ($numb !== 0) {
                if ($numb !== 1 || $power !== 2) {
                    $ret .= $this->showDigitsGroup(
                        $numb,
                        $i + 1 === $sizeOfNumberGroups || $power > 2
                    ) . $this->wordSeparator;
                }

                $ret .= self::$exponent[($power - 1) * 3];

                if ($power > 2 && $numb > 1) {
                    $ret .= $this->pluralSuffix;
                }

                $ret .= $this->wordSeparator;
            }
        }

        return rtrim($ret, $this->wordSeparator);
    }
988138
public function numberToRomanNumerals(int $number): string
    {
        if ($number < 1) {
            // Cannot convert zero/negative numbers
            return (string) $number;
        }
        $roman = '';
        foreach (self::ROMAN_NUMERALS as $key => $value) {
            while ($number >= $key) {
                $roman  .= $value;
                $number -= $key;
            }
        }

        return $roman;
    }
567153
private function strConst($number) {
        static $lookup;
        if (!$lookup) {
            $lookup = array();
            $r = new ReflectionClass('HTML5_TreeBuilder');
            $consts = $r->getConstants();
            foreach ($consts as $const => $num) {
                if (!is_int($num)) continue;
                $lookup[$num] = $const;
            }
        }
        return $lookup[$number];
    }
63386
private static function size($number, int $decimal = 2, bool $binary = false)
	{
		return Number::size(self::prepareFloat($number), $decimal, $binary);
	}
904596
public static function number_to_word($number)
    {
        $number = (string) $number;

        if (strpos($number, '.') !== false) {
            list($number, $decimal) = explode('.', $number);
        } else {
            $decimal = false;
        }

        $output = '';

        if ($number[0] == '-') {
            $output = 'negative ';
            $number = ltrim($number, '-');
        } elseif ($number[0] == '+') {
            $output = 'positive ';
            $number = ltrim($number, '+');
        }

        if ($number[0] == '0') {
            $output .= 'zero';
        } else {
            $length = 19;
            $number = str_pad($number, 60, '0', STR_PAD_LEFT);
            $group  = rtrim(chunk_split($number, 3, ' '), ' ');
            $groups = explode(' ', $group);
            $groups2 = array();

            foreach ($groups as $group) {
                $group[1] = isset($group[1]) ? $group[1] : null;
                $group[2] = isset($group[2]) ? $group[2] : null;
                $groups2[] = self::numberToWordThreeDigits($group[0], $group[1], $group[2]);
            }

            for ($z = 0; $z < count($groups2); $z++) {
                if ($groups2[$z] != '') {
                    $output .= $groups2[$z] . self::numberToWordConvertGroup($length - $z);
                    $output .= ($z < $length && ! array_search('', array_slice($groups2, $z + 1, -1)) && $groups2[$length] != '' && $groups[$length][0] == '0' ? ' and ' : ', ');
                }
            }

            $output = rtrim($output, ', ');
        }

        if ($decimal > 0) {
            $output .= ' point';

            for ($i = 0; $i < strlen($decimal); $i++) {
                $output .= ' ' . self::numberToWordConvertDigit($decimal[$i]);
            }
        }

        return $output;
    }
971824
public static function decimalToAlphanumeric($number, $base = 64, $index = false)
    {
        if (!$base) {
            $base = strlen($index);
        } elseif (!$index) {
            $index = substr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base);
        }

        $out = "";

        for ($i = floor(log10($number) / log10($base)); $i >= 0; $i--) { 
            $no = floor($num/pow($base, $i));
            $out = $out.substr($index, $no, 1);
            $number = $number - ($no * pow($base, $i));
        }
        return $out;
    }
1316522
private function getPluralRule($number)
    {
        // One
        if ($number === Dictionary::$thresholdFew) {
            return 'o';
        }

        // Zero, which behaves like few
        if ($number === 0) {
            return 'f';
        }

        $uz = $number % 100;

        // Hundreds behave like many
        if ($uz === 0) {
            return 'm';
        }

        // Many
        if ($uz > Dictionary::$thresholdMany) {
            return 'm';
        }

        // Below the many threshold, so few
        return 'f';
    }
748877
protected static function creditCardType($number)
    {
        foreach (self::$cards as $type => $card) {
            if (preg_match($card['pattern'], $number)) {
                return $type;
            }
        }

        return '';
    }
580891
protected function toWords($number)
    {
        if ($number === 0) {
            return $this->zero;
        }

        $out = [];

        if ($number < 0) {
            $out[] = $this->minus;
            $number *= -1;
        }

        $megaSize = count(static::$mega);
        $signs = $megaSize * 3;

        // $signs equal quantity of zeros of the biggest number in self::$mega
        // + 3 additional sign (point and two zero)
        list ($unit, $subunit) = explode('.', sprintf("%{$signs}.2f", (float) $number));

        // return sprintf("%{1}.2f", (float) $number);

        foreach (str_split($unit, 3) as $megaKey => $value) {
            if (!(int) $value) {
                continue;
            }

            $megaKey = $megaSize - $megaKey - 1;
            // $gender = static::$mega[$megaKey][3];
            list ($i1, $i2, $i3) = array_map('intval', str_split($value, 1));
            // mega-logic
            if ($i1 > 0) {
                $out[] = static::$ten[$i1] . ' ýüz'; # 1xx-9xx
            }
            
            // tens
            if ($i2 > 0) {
                $out[] = static::$tens[$i2];
            }

            // ones
            if ($i3 > 0) {
                $out[] = static::$ten[$i3];
            }

            if ($megaKey > 1) {
                $out[] = static::$mega[$megaKey];
            }
        }

        return trim(preg_replace('/\s+/', ' ', implode(' ', $out)));
    }