public function testSumsDecimalsInArray1() { $this->assertEquals('3.00', strval(Decimal2::sum([new Decimal2('1'), new Decimal2('1'), new Decimal2('2'), new Decimal2('-1')]))); }
/** * Returns the average of all the decimal numbers in the array. * * @param array $decimals The array of Decimal2 objects. * * @return Decimal2 or boolean false for an empty $decimals array. */ public static function avg(array $decimals) { if (!count($decimals)) { return false; } return Decimal2::div(Decimal2::sum($decimals), new Decimal2(count($decimals))); }