From acdd5dc54d94fc79487999de1e0d70c136fb7b3d Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Fri, 25 Mar 2022 22:23:14 +0100 Subject: [PATCH] Deprecate doubleValue() in favor of floatValue() --- ChangeLog.md | 1 + README.md | 58 ++++++++++++++---------------- src/main/php/math/BigNum.class.php | 14 ++++---- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index e281dd7..0cb985e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ XP Math changelog ## ?.?.? / ????-??-?? +* Deprecated doubleValue() in favor of floatValue() - @thekid * Merged PR #3: Comparison and equality - @thekid ## 9.0.2 / 2022-03-25 diff --git a/README.md b/README.md index 1565d3e..5503c23 100755 --- a/README.md +++ b/README.md @@ -15,29 +15,26 @@ API: BigInt ```php public class math.BigInt extends math.BigNum { - - public math.BigInt __construct(string $in) - - protected static string bytesOf(var $n) - - public math.BigNum add(var $other) - public math.BigNum subtract(var $other) - public math.BigNum multiply(var $other) - public math.BigNum divide(var $other) - public math.BigNum add0(var $other) - public math.BigNum subtract0(var $other) - public math.BigNum multiply0(var $other) - public math.BigNum divide0(var $other) - public math.BigNum power(var $other) - public math.BigNum modulo(var $other) - public math.BigNum bitwiseAnd(var $other) - public math.BigNum bitwiseOr(var $other) - public math.BigNum bitwiseXor(var $other) - public math.BigNum shiftRight(var $shift) - public math.BigNum shiftLeft(var $shift) + public math.BigInt __construct(int|float|string|parent $in) + + public math.BigNum add(int|float|string|parent $other) + public math.BigNum subtract(int|float|string|parent $other) + public math.BigNum multiply(int|float|string|parent $other) + public math.BigNum divide(int|float|string|parent $other) + public math.BigNum add0(int|float|string|parent $other) + public math.BigNum subtract0(int|float|string|parent $other) + public math.BigNum multiply0(int|float|string|parent $other) + public math.BigNum divide0(int|float|string|parent $other) + public math.BigNum power(int|float|string|parent $other) + public math.BigNum modulo(int|float|string|parent $other) + public math.BigNum bitwiseAnd(int|float|string|parent $other) + public math.BigNum bitwiseOr(int|float|string|parent $other) + public math.BigNum bitwiseXor(int|float|string|parent $other) + public math.BigNum shiftRight(int|float|string|parent $shift) + public math.BigNum shiftLeft(int|float|string|parent $shift) public int byteValue() public int intValue() - public int doubleValue() + public float floatValue() } ``` @@ -46,20 +43,19 @@ API: BigFloat ```php public class math.BigFloat extends math.BigNum { - protected var math.BigNum::$num - - public math.BigFloat __construct(string $in) + public math.BigFloat __construct(int|float|string|parent $in) - public math.BigNum add(var $other) - public math.BigNum subtract(var $other) - public math.BigNum multiply(var $other) - public math.BigNum divide(var $other) - public math.BigNum power(var $other) + public math.BigNum add(int|float|string|parent $other) + public math.BigNum subtract(int|float|string|parent $other) + public math.BigNum multiply(int|float|string|parent $other) + public math.BigNum divide(int|float|string|parent $other) + public math.BigNum power(int|float|string|parent $other) public math.BigFloat ceil() public math.BigFloat floor() public math.BigFloat round([int $precision= 0]) - public bool equals(lang.Generic $cmp) + public int compare(int|float|string|parent $other, ?int $precision= null) + public bool equals(int|float|string|parent $other, ?int $precision= null) public int intValue() - public int doubleValue() + public float floatValue() } ``` \ No newline at end of file diff --git a/src/main/php/math/BigNum.class.php b/src/main/php/math/BigNum.class.php index 64a219a..476dca8 100755 --- a/src/main/php/math/BigNum.class.php +++ b/src/main/php/math/BigNum.class.php @@ -51,16 +51,16 @@ public abstract function multiply($other); */ public abstract function divide($other); - /** - * Returns an integer representing this bignum - * - * @return int - */ - public function intValue() { return (int)substr($this->num, 0, strcspn($this->num, '.')); } + /** Returns an integer representing this bignum */ + public function intValue(): int { return (int)$this->num; } + + /** Returns an float representing this bignum */ + public function floatValue(): float { return (float)$this->num; } /** - * Returns a double representing this bignum + * Returns a float representing this bignum * + * @deprecated Use floatValue() instead * @return double */ public function doubleValue() { return (double)$this->num; }