/** * Computes the sum of all numbers in this list * @return string */ public function sum() { Number::setScale(static::NUMERIC_FUNCTIONS_SCALE); $total = '0'; foreach ($this->_Arr as $item) { $total = Number::add($total, \strval($item)); } return $total; }
/** * Converts the set to an integer string. The difference between this * and toInt() is that this method uses bcmath functions to handle * large bit sets that would fail to properly be converted to a PHP * integer if toInt() is used. * @return string */ public function toLongInt() { $total = '0'; for ($i = 0, $l = $this->count(); $i < $l; ++$i) { if ($this->_List[$i]) { $total = Number::add($total, Number::pow('2', (string) $i)); } } return $total; }
public function trimZeros() { $this->assertEquals('0', Number::sub('1', '1')); $this->assertEquals('0.01', Number::add('0.00000', '0.01')); }