@@ 262-267 (lines=6) @@ | ||
259 | // direct $n<=PHP_INT_MAX check is unreliable on 64bit (values close to max) due to limited float precision |
|
260 | if (bcadd($n, -PHP_INT_MAX, 0) <= 0) { |
|
261 | // trick explained in http://www.php.net/manual/fr/function.pack.php#109328 |
|
262 | if ($this->is64bits) { |
|
263 | list($hi, $lo) = $this->splitIntoQuads($n); |
|
264 | } else { |
|
265 | $hi = 0; |
|
266 | $lo = $n; |
|
267 | } //on 32bits hi quad is 0 a priori |
|
268 | $this->out .= pack('NN', $hi, $lo); |
|
269 | } else { |
|
270 | try { |
|
@@ 283-288 (lines=6) @@ | ||
280 | public function write_signed_longlong($n) |
|
281 | { |
|
282 | if ((bcadd($n, PHP_INT_MAX, 0) >= -1) && (bcadd($n, -PHP_INT_MAX, 0) <= 0)) { |
|
283 | if ($this->is64bits) { |
|
284 | list($hi, $lo) = $this->splitIntoQuads($n); |
|
285 | } else { |
|
286 | $hi = $n < 0 ? -1 : 0; |
|
287 | $lo = $n; |
|
288 | } //0xffffffff for negatives |
|
289 | $this->out .= pack('NN', $hi, $lo); |
|
290 | } elseif ($this->is64bits) { |
|
291 | throw new AMQPInvalidArgumentException('Signed longlong out of range: ' . $n); |