-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy path_dneg.php
More file actions
34 lines (28 loc) · 856 Bytes
/
_dneg.php
File metadata and controls
34 lines (28 loc) · 856 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
34
<?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 _dneg 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();
$value = Normalizer::getPrimitiveValue(
$this->popFromOperandStack()
);
$result = (string) BigDecimal::of($value)
->multipliedBy(BigDecimal::of(-1));
$this->pushToOperandStack(Double_::get($result));
}
}