This repository was archived by the owner on Dec 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -340,20 +340,16 @@ public function pow(Decimal $b, int $scale = null): Decimal
340
340
$ pow_scale
341
341
);
342
342
} else { // elseif ($this->isNegative())
343
- if ($ b ->isInteger ()) {
344
- if (\preg_match ('/^[+\-]?[0-9]*[02468](\.0+)?$/ ' , $ b ->value , $ captures ) === 1 ) {
345
- // $b is an even number
346
- return $ this ->additiveInverse ()->pow ($ b , $ scale );
347
- } else {
348
- // $b is an odd number
349
- return $ this ->additiveInverse ()->pow ($ b , $ scale )->additiveInverse ();
350
- }
343
+ if (!$ b ->isInteger ()) {
344
+ throw new NotImplementedError (
345
+ "Usually negative numbers can't be powered to non integer numbers. " .
346
+ "The cases where is possible are not implemented. "
347
+ );
351
348
}
352
349
353
- throw new NotImplementedError (
354
- "Usually negative numbers can't be powered to non integer numbers. " .
355
- "The cases where is possible are not implemented. "
356
- );
350
+ return (\preg_match ('/^[+\-]?[0-9]*[02468](\.0+)?$/ ' , $ b ->value , $ captures ) === 1 )
351
+ ? $ this ->additiveInverse ()->pow ($ b , $ scale ) // $b is an even number
352
+ : $ this ->additiveInverse ()->pow ($ b , $ scale )->additiveInverse (); // $b is an odd number
357
353
}
358
354
}
359
355
}
You can’t perform that action at this time.
0 commit comments