Guest User

Untitled

a guest
Dec 11th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. function read64_int($db) {
  2.         $first = reset(unpack('N', fread($db, 4)));
  3.         $second = reset(unpack('N', fread($db, 4)));
  4.  
  5.         // Get whether -ve
  6.         $negative = (bool)($first & 128);
  7.  
  8.         // Strip the sign
  9.         $first &= 127;
  10.  
  11.         // Add the two
  12.         $result = ($first << 8) + $second;
  13.  
  14.         // Make it -ve if we need to
  15.         if ($negative)
  16.                 $result *= -1;
  17.  
  18.         // Return
  19.         return $result;
  20. }
Add Comment
Please, Sign In to add comment