@@ 2151-2158 (lines=8) @@ | ||
2148 | protected function newFromNum($bits, $num) { |
|
2149 | $bstream = $this->allocate($bits); |
|
2150 | $mask = 1 << ($bits - 1); |
|
2151 | for ($i = 0; $i < $bits; ++$i) { |
|
2152 | if ($num & $mask) { |
|
2153 | $bstream[$i] = 1; |
|
2154 | } else { |
|
2155 | $bstream[$i] = 0; |
|
2156 | } |
|
2157 | $mask = $mask >> 1; |
|
2158 | } |
|
2159 | return $bstream; |
|
2160 | } |
|
2161 | ||
@@ 2173-2181 (lines=9) @@ | ||
2170 | $p = 0; |
|
2171 | for ($i = 0; $i < $size; ++$i) { |
|
2172 | $mask = 0x80; |
|
2173 | for ($j = 0; $j < 8; ++$j) { |
|
2174 | if ($data[$i] & $mask) { |
|
2175 | $bstream[$p] = 1; |
|
2176 | } else { |
|
2177 | $bstream[$p] = 0; |
|
2178 | } |
|
2179 | $p++; |
|
2180 | $mask = $mask >> 1; |
|
2181 | } |
|
2182 | } |
|
2183 | return $bstream; |
|
2184 | } |