private static function computeSquareIndex(
        string $exponent_remaining,
        int $actual_index,
        int $exp_scale,
        int $inner_scale
    ): array
    {
        $actual_rt = \bcpow('0.5', (string)$actual_index, $exp_scale);
        $r = \bcsub($exponent_remaining, $actual_rt, $inner_scale);

        while (\bccomp($r, '0', $exp_scale) === -1) {
            ++$actual_index;
            $actual_rt = \bcmul('0.5', $actual_rt, $inner_scale);
            $r = \bcsub($exponent_remaining, $actual_rt, $inner_scale);
        }

        return [$actual_index, $r];
    }
private static function computeSquareIndex(
        string $exponent_remaining,
        int $actual_index,
        int $exp_scale,
        int $inner_scale
    ): array
    {
        $actual_rt = \bcpow('0.5', (string)$actual_index, $exp_scale);
        $r = \bcsub($exponent_remaining, $actual_rt, $inner_scale);

        while (\bccomp($r, '0', $exp_scale) === -1) {
            ++$actual_index;
            $actual_rt = \bcmul('0.5', $actual_rt, $inner_scale);
            $r = \bcsub($exponent_remaining, $actual_rt, $inner_scale);
        }

        return [$actual_index, $r];
    }
private static function computeSquareIndex ( string $ exponent_remaining , int $ actual_index , int $ exp_scale , int $ inner_scale ) : array { $ actual_rt = \ bcpow ( '0.5' , ( string ) $ actual_index , $ exp_scale ) ; $ r = \ bcsub ( $ exponent_remaining , $ actual_rt , $ inner_scale ) ; while ( \ bccomp ( $ r , '0' , $ exp_scale ) === - 1 ) { ++ $ actual_index ; $ actual_rt = \ bcmul ( '0.5' , $ actual_rt , $ inner_scale ) ; $ r = \ bcsub ( $ exponent_remaining , $ actual_rt , $ inner_scale ) ; } return [ $ actual_index , $ r ] ; }
Auxiliar method. It helps us to decompose the exponent into many summands.

@param  string $exponent_remaining
@param  int    $actual_index
@param  int    $exp_scale           Number of $exponent's significative digits
@param  int    $inner_scale         ceil($exp_scale*log(10)/log(2))+1;
@return array
Auxiliar method . It helps us to decompose the exponent into many summands .