-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy path_dsub.php
More file actions
33 lines (27 loc) · 913 Bytes
/
_dsub.php
File metadata and controls
33 lines (27 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace PHPJava\Kernel\Mnemonics;
use Brick\Math\BigDecimal;
use PHPJava\Kernel\Filters\Normalizer;
use PHPJava\Kernel\Types\Double_;
final class _dsub extends AbstractOperationCode implements OperationCodeInterface
{
protected $isStackingOperation = true;
public function getOperands(): ?Operands
{
parent::getOperands();
if ($this->operands !== null) {
return $this->operands;
}
return $this->operands = new Operands();
}
public function execute(): void
{
parent::execute();
$value2 = Normalizer::getPrimitiveValue($this->popFromOperandStack());
$value1 = Normalizer::getPrimitiveValue($this->popFromOperandStack());
$result = (string) BigDecimal::of($value1)
->minus(BigDecimal::of($value2));
$this->pushToOperandStack(Double_::get($result));
}
}