I'm looking for a table of translation : how to translate interger from 0 to 255 into binary code ==> 2 = 10 etc...
I really need this table, please help me !
I really need this table, please help me !
| Code: |
|
example : 169 1 ) ( 169>=128 ) YES b ) 1??????? c ) 169-128=41 2 ) ( 41 >=64 ) NO b ) 10?????? c ) 41 3 ) ( 41 >=32 ) YES b ) 101????? c ) 41-32=9 4 ) ( 9 >=16 ) NO b ) 1010???? c ) 9 5 ) ( 9 >=8 ) YES b ) 10101??? c ) 9-8=1 6 ) ( 1 >=4 ) NO b ) 101010?? c ) 1 7 ) ( 1 >=2 ) NO b ) 1010100? c ) 1 8 ) ( 1 >=1 ) YES b ) 10101001 c ) 1-1=0 |
| Code: |
| <?php
functtion dec2bin($d) { $b = ''; while ($d>0) { $r = $d % 2; $d = floor($d / 2); $b = $r.$b; } return $b; } for ($i=0; $i<256; $i++) { echo $i.'=>'.dec2bin($i).'<br />'; } ?> |