diff --git a/src/main/php/math/BigFloat.class.php b/src/main/php/math/BigFloat.class.php index 8dce7e6..def2b17 100755 --- a/src/main/php/math/BigFloat.class.php +++ b/src/main/php/math/BigFloat.class.php @@ -14,7 +14,7 @@ class BigFloat extends BigNum { /** * Creates a new BigFloat instance * - * @param string in + * @param int|float|string $in */ public function __construct($in) { $this->num= false !== strpos($in, '.') ? rtrim(rtrim($in, '0'), '.') : (string)$in; @@ -23,8 +23,8 @@ public function __construct($in) { /** * + * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function add($other) { return new self(bcadd($this->num, $other instanceof self ? $other->num : $other)); @@ -33,8 +33,8 @@ public function add($other) { /** * - * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function subtract($other) { return new self(bcsub($this->num, $other instanceof self ? $other->num : $other)); @@ -43,8 +43,8 @@ public function subtract($other) { /** * * * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function multiply($other) { return new self(bcmul($this->num, $other instanceof self ? $other->num : $other)); @@ -53,8 +53,8 @@ public function multiply($other) { /** * / * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function divide($other) { try { @@ -72,9 +72,9 @@ public function divide($other) { /** * ^ * - * @see http://en.wikipedia.org/wiki/Exponentiation - * @param var other - * @return math.BigNum + * @see http://en.wikipedia.org/wiki/Exponentiation + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function power($other) { return new self(bcpow($this->num, $other instanceof self ? $other->num : $other)); @@ -83,7 +83,7 @@ public function power($other) { /** * Returns the next lowest "integer" value by rounding down value if necessary. * - * @return math.BigFloat + * @return self */ public function ceil() { return new self(false === strpos($this->num, '.') @@ -95,7 +95,7 @@ public function ceil() { /** * Returns the next highest "integer" value by rounding up value if necessary * - * @return math.BigFloat + * @return self */ public function floor() { return new self(false === strpos($this->num, '.') @@ -108,8 +108,8 @@ public function floor() { * Returns the rounded value of val to specified precision (number of digits * after the decimal point). * - * @param int precision - * @return math.BigFloat + * @param int $precision + * @return self */ public function round($precision= 0) { if (false === strpos($this->num, '.')) return new self($this->num); diff --git a/src/main/php/math/BigInt.class.php b/src/main/php/math/BigInt.class.php index 7abcd2f..0da2d62 100755 --- a/src/main/php/math/BigInt.class.php +++ b/src/main/php/math/BigInt.class.php @@ -14,7 +14,7 @@ class BigInt extends BigNum { /** * Creates a new BigInt instance * - * @param string in + * @param int|float|string $in */ public function __construct($in) { $this->num= substr($in, 0, strcspn($in, '.')); @@ -23,8 +23,8 @@ public function __construct($in) { /** * + * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function add($other) { if ($other instanceof self) { @@ -41,8 +41,8 @@ public function add($other) { /** * - * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function subtract($other) { if ($other instanceof self) { @@ -59,8 +59,8 @@ public function subtract($other) { /** * * * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function multiply($other) { if ($other instanceof self) { @@ -77,8 +77,8 @@ public function multiply($other) { /** * / * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function divide($other) { try { @@ -119,8 +119,8 @@ public function divide($other) { /** * +(0), strictly integer addition * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function add0($other) { return new self(bcadd($this->num, $other instanceof parent ? $other->num : $other, 0)); @@ -129,8 +129,8 @@ public function add0($other) { /** * -(0), strictly integer subtraction * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function subtract0($other) { return new self(bcsub($this->num, $other instanceof parent ? $other->num : $other, 0)); @@ -139,8 +139,8 @@ public function subtract0($other) { /** * *(0), strictly integer multiplication * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function multiply0($other) { return new self(bcmul($this->num, $other instanceof self ? $other->num : $other, 0)); @@ -149,8 +149,8 @@ public function multiply0($other) { /** * / * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function divide0($other) { try { @@ -169,8 +169,8 @@ public function divide0($other) { * ^ * * @see http://en.wikipedia.org/wiki/Exponentiation - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function power($other) { if ($other instanceof self) { @@ -193,8 +193,8 @@ public function power($other) { /** * % * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function modulo($other) { try { @@ -212,8 +212,8 @@ public function modulo($other) { /** * & * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function bitwiseAnd($other) { $a= self::bytesOf($this->num); @@ -225,8 +225,8 @@ public function bitwiseAnd($other) { /** * | * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function bitwiseOr($other) { $a= self::bytesOf($this->num); @@ -238,8 +238,8 @@ public function bitwiseOr($other) { /** * ^ * - * @param var other - * @return math.BigNum + * @param math.BigNum|int|float|string $other + * @return math.BigNum */ public function bitwiseXor($other) { $a= self::bytesOf($this->num); @@ -252,7 +252,7 @@ public function bitwiseXor($other) { * >> * * @param var shift - * @return math.BigNum + * @return math.BigNum */ public function shiftRight($shift) { return new self(bcdiv($this->num, bcpow(2, $shift instanceof self ? $shift->num : $shift, 0), 0)); @@ -262,7 +262,7 @@ public function shiftRight($shift) { * << * * @param var shift - * @return math.BigNum + * @return math.BigNum */ public function shiftLeft($shift) { return new self(bcmul($this->num, bcpow(2, $shift instanceof self ? $shift->num : $shift, 0), 0)); @@ -273,7 +273,7 @@ public function shiftLeft($shift) { * * @see xp://math.BigNum#toBytes * @param string bytes - * @return math.BigNum + * @return math.BigNum */ protected static function fromBytes($bytes) { $len= strlen($bytes); @@ -294,7 +294,7 @@ protected static function fromBytes($bytes) { * Creates sequence of bytes from a bignum * * @see xp://math.BigNum#fromBytes - * @return string + * @return string */ protected static function bytesOf($n) { $value= ''; @@ -308,7 +308,7 @@ protected static function bytesOf($n) { /** * Returns an byte representing this big integer * - * @return int + * @return int */ public function byteValue() { return $this->bitwiseAnd(0xFF)->intValue(); diff --git a/src/main/php/math/BigNum.class.php b/src/main/php/math/BigNum.class.php index fa9e2eb..b82fa92 100755 --- a/src/main/php/math/BigNum.class.php +++ b/src/main/php/math/BigNum.class.php @@ -21,38 +21,32 @@ static function __static() { /** * + * - * @param var other - * @return math.BigNum + * @param self|int|float|string $other + * @return self */ - public function add($other) { - return new static(bcadd($this->num, $other instanceof self ? $other->num : $other)); - } + public abstract function add($other); /** * - * - * @param var other - * @return math.BigNum + * @param self|int|float|string $other + * @return self */ - public function subtract($other) { - return new static(bcsub($this->num, $other instanceof self ? $other->num : $other)); - } + public abstract function subtract($other); /** * * * - * @param var other - * @return math.BigNum + * @param self|int|float|string $other + * @return self */ - public function multiply($other) { - return new static(bcmul($this->num, $other instanceof self ? $other->num : $other)); - } + public abstract function multiply($other); /** * / * - * @param var other - * @return math.BigNum + * @param self|int|float|string $other + * @return self */ public abstract function divide($other);