We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8366cb8 commit 79bcae7Copy full SHA for 79bcae7
1 file changed
src/Kernel/Mnemonics/_lcmp.php
@@ -1,7 +1,8 @@
1
<?php
2
namespace PHPJava\Kernel\Mnemonics;
3
4
-use PHPJava\Exceptions\NotImplementedException;
+use Brick\Math\BigInteger;
5
+use PHPJava\Kernel\Types\_Int;
6
7
final class _lcmp implements OperationInterface
8
{
@@ -10,6 +11,21 @@ final class _lcmp implements OperationInterface
10
11
12
public function execute(): void
13
- throw new NotImplementedException(__CLASS__);
14
+ $value2 = $this->popFromOperandStack();
15
+ $value1 = $this->popFromOperandStack();
16
+
17
+ $compare = BigInteger::of($value1)->compareTo($value2);
18
19
+ if ($compare == 1) {
20
+ $this->pushToOperandStack(_Int::get(1));
21
+ return;
22
+ }
23
24
+ if ($compare == -1) {
25
+ $this->pushToOperandStack(_Int::get(-1));
26
27
28
29
+ $this->pushToOperandStack(_Int::get(0));
30
}
31
0 commit comments