Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 40c9288

Browse files
committed
Added documentation
1 parent 7f84384 commit 40c9288

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/Litipk/BigNumbers/Decimal.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,15 @@ private static function innerLog10 ($value, $in_scale, $out_scale)
694694
}
695695
}
696696

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+
*/
698706
private static function innerPowWithLittleExponent ($base, $exponent, $exp_scale, $out_scale)
699707
{
700708
$inner_scale = ceil($exp_scale*log(10)/log(2))+1;
@@ -715,7 +723,15 @@ private static function innerPowWithLittleExponent ($base, $exponent, $exp_scale
715723
return self::innerRound($result_a, $out_scale);
716724
}
717725

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+
*/
719735
private static function computeSquareIndex ($exponent_remaining, $actual_index, $exp_scale, $inner_scale)
720736
{
721737
$actual_rt = bcpow('0.5', $actual_index, $exp_scale);
@@ -726,11 +742,18 @@ private static function computeSquareIndex ($exponent_remaining, $actual_index,
726742
$actual_rt = bcmul('0.5', $actual_rt, $inner_scale);
727743
$r = bcsub($exponent_remaining, $actual_rt, $inner_scale);
728744
}
729-
745+
730746
return [$actual_index, $r];
731747
}
732748

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+
*/
734757
private static function compute2NRoot ($base, $index, $out_scale)
735758
{
736759
$result = $base;

0 commit comments

Comments
 (0)