update #5
@ -13,7 +13,6 @@
|
||||
abstract MathHelper #Orange {
|
||||
+ {static} bc(string $type, int $val1, ...) : string|int|null|bool
|
||||
+ {static} sum(array $array, int $scale = 4) : float
|
||||
+ {static} sum(array $array, int $scale = 4) : float
|
||||
}
|
||||
|
||||
note right of MathHelper::bc
|
||||
@ -32,10 +31,6 @@ end note
|
||||
note right of MathHelper::sum
|
||||
Basic sum of an array with more precision
|
||||
|
||||
since: 3.0.9
|
||||
return: float
|
||||
Basic sum of an array with more precision
|
||||
|
||||
since: 3.0.9
|
||||
return: float
|
||||
end note
|
||||
|
@ -97,34 +97,6 @@ abstract class MathHelper
|
||||
// fall back on array sum
|
||||
return array_sum($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic sum of an array with more precision
|
||||
*
|
||||
* @param array $array The values to sum
|
||||
* @param int $scale The scale value
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static function sum($array, $scale = 4)
|
||||
{
|
||||
// use the bcadd function if available
|
||||
if (function_exists('bcadd'))
|
||||
{
|
||||
// set the start value
|
||||
$value = 0.0;
|
||||
// loop the values and run bcadd
|
||||
foreach($array as $val)
|
||||
{
|
||||
$value = bcadd($value, (string) $val, $scale);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
// fall back on array sum
|
||||
return array_sum($array);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,31 +76,3 @@
|
||||
// fall back on array sum
|
||||
return array_sum($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic sum of an array with more precision
|
||||
*
|
||||
* @param array $array The values to sum
|
||||
* @param int $scale The scale value
|
||||
*
|
||||
* @return float
|
||||
*
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static function sum($array, $scale = 4)
|
||||
{
|
||||
// use the bcadd function if available
|
||||
if (function_exists('bcadd'))
|
||||
{
|
||||
// set the start value
|
||||
$value = 0.0;
|
||||
// loop the values and run bcadd
|
||||
foreach($array as $val)
|
||||
{
|
||||
$value = bcadd($value, (string) $val, $scale);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
// fall back on array sum
|
||||
return array_sum($array);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user