Skip to content

Commit

Permalink
Use [] for array offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Dec 1, 2019
1 parent da19172 commit 68b4385
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main/php/math/BigFloat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function power($other) {
public function ceil() {
return new self(false === strpos($this->num, '.')
? $this->num
: ('-' === $this->num{0} ? bcsub($this->num, 0, 0) : bcadd($this->num, 1, 0))
: ('-' === $this->num[0] ? bcsub($this->num, 0, 0) : bcadd($this->num, 1, 0))
);
}

Expand All @@ -94,7 +94,7 @@ public function ceil() {
public function floor() {
return new self(false === strpos($this->num, '.')
? $this->num
: ('-' === $this->num{0} ? bcsub($this->num, 1, 0) : bcadd($this->num, 0, 0))
: ('-' === $this->num[0] ? bcsub($this->num, 1, 0) : bcadd($this->num, 0, 0))
);
}

Expand All @@ -111,7 +111,7 @@ public function round($precision= 0) {
$a= '0.'.str_repeat('0', $precision).'5';
return new self(false === strpos($this->num, '.')
? $this->num
: ('-' === $this->num{0} ? bcsub($this->num, $a, $precision) : bcadd($this->num, $a, $precision))
: ('-' === $this->num[0] ? bcsub($this->num, $a, $precision) : bcadd($this->num, $a, $precision))
);
}
}
2 changes: 1 addition & 1 deletion src/main/php/math/BigInt.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ protected static function fromBytes($bytes) {
$bytes= str_pad($bytes, $len, "\0", STR_PAD_LEFT);
$self= new self(0);
for ($i= 0; $i < $len; $i+= 4) {
$self->num= bcadd(bcmul($self->num, '4294967296'), 0x1000000 * ord($bytes{$i}) + current(unpack('N', "\0".substr($bytes, $i+ 1, 3))));
$self->num= bcadd(bcmul($self->num, '4294967296'), 0x1000000 * ord($bytes[$i]) + current(unpack('N', "\0".substr($bytes, $i+ 1, 3))));
}
return $self;
}
Expand Down

0 comments on commit 68b4385

Please sign in to comment.