note 61478 deleted from language.operators.bitwise by cmb

From: Date: Sun, 20 Oct 2019 08:48:49 +0000
Subject: note 61478 deleted from language.operators.bitwise by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212694@lists.php.net to get a copy of this message
Note Submitter: Xavier Daull ---- <?php // Extract part of a binary data - due to windows system limitations (and this code), bit extracted length($firstbit to $lastbit included) is limited to 31 bits function sub_bindata($mybindata, $firstbit = 7, $lastbit = 0, $highestbitfirst = true) { // 1. Create a bit mask of the right size by triming left and right // 2. select bits by an AND on $mybindata // 3. shift right to get only length needed if($highestbitfirst) return (((0x7FFFFFFF >> (30+$lastbit-$firstbit))<<($lastbit)) & $mybindata) >> ($lastbit); else return (((0x7FFFFFFF >> (30-$lastbit+$firstbit))<<(30-$lastbit)) & $mybindata) >> (30-$lastbit); } ?>

« previous php.notes (#212694) next »