@@ -694,7 +694,15 @@ private static function innerLog10 ($value, $in_scale, $out_scale)
694
694
}
695
695
}
696
696
697
-
697
+ /**
698
+ * Returns $base^$exponent
699
+ *
700
+ * @param string $base
701
+ * @param string $exponent 0 < $exponent < 1
702
+ * @param integer $exp_scale Number of $exponent's significative digits
703
+ * @param integer $out_scale Number of significative digits that we want to compute
704
+ * @return string
705
+ */
698
706
private static function innerPowWithLittleExponent ($ base , $ exponent , $ exp_scale , $ out_scale )
699
707
{
700
708
$ inner_scale = ceil ($ exp_scale *log (10 )/log (2 ))+1 ;
@@ -715,7 +723,15 @@ private static function innerPowWithLittleExponent ($base, $exponent, $exp_scale
715
723
return self ::innerRound ($ result_a , $ out_scale );
716
724
}
717
725
718
-
726
+ /**
727
+ * Auxiliar method. It helps us to decompose the exponent into many summands.
728
+ *
729
+ * @param string $exponent_remaining
730
+ * @param integer $actual_index
731
+ * @param integer $exp_scale Number of $exponent's significative digits
732
+ * @param integer $inner_scale ceil($exp_scale*log(10)/log(2))+1;
733
+ * @return array
734
+ */
719
735
private static function computeSquareIndex ($ exponent_remaining , $ actual_index , $ exp_scale , $ inner_scale )
720
736
{
721
737
$ actual_rt = bcpow ('0.5 ' , $ actual_index , $ exp_scale );
@@ -726,11 +742,18 @@ private static function computeSquareIndex ($exponent_remaining, $actual_index,
726
742
$ actual_rt = bcmul ('0.5 ' , $ actual_rt , $ inner_scale );
727
743
$ r = bcsub ($ exponent_remaining , $ actual_rt , $ inner_scale );
728
744
}
729
-
745
+
730
746
return [$ actual_index , $ r ];
731
747
}
732
748
733
-
749
+ /**
750
+ * Auxiliar method. Computes $base^((1/2)^$index)
751
+ *
752
+ * @param string $base
753
+ * @param integer $index
754
+ * @param integer $out_scale
755
+ * @return string
756
+ */
734
757
private static function compute2NRoot ($ base , $ index , $ out_scale )
735
758
{
736
759
$ result = $ base ;
0 commit comments