We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a02c3ef commit 8864a03Copy full SHA for 8864a03
src/Simple/BCMath.php
@@ -111,17 +111,15 @@ public function round($number, int $precision = 0): string
111
*/
112
public function abs($number): string
113
{
114
- try {
115
- $this->add($number, 0); // validator
116
- if ($this->isNegative($number)) {
117
- return substr($number, 1);
118
- }
119
-
120
- return $number;
121
- } catch (\Throwable $throwable) {
122
- // this is not a number
+ if (!preg_match('~^-?\d+(\.\d+)?~', $number)) {
123
return 0;
124
}
+
+ if ($this->isNegative($number)) {
+ return substr($number, 1);
+ }
+ return $number;
125
126
127
/**
0 commit comments