-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtmp.php
More file actions
62 lines (47 loc) · 926 Bytes
/
tmp.php
File metadata and controls
62 lines (47 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*if((0 XOR 0 XOR 0 XOR 0) == 1)
{
echo 1;
}
else
{
echo 0;
}*/
echo 'X'.chr(9).'X';
echo dec_to_bin(68,8);
function dec_to_bin($x,$p_num_bits = 8)
{
// Convert to binary
$bin_str = decbin($x);
$array_bin = Array();
echo $bin_str.'<hr />';
$substr = -1;
for($i = $p_num_bits;$i > 0;$i--)
{
if(strlen($bin_str)-$p_num_bits <= $i)
{
//echo substr($bin_str,$substr,1).'<hr />';
echo $substr.'<hr />';
}
else
{
echo strlen($bin_str).' >= '.$i.'<hr />';
}
$substr -= 1;
}
}
function fmt_binary($x,$numbits = 8)
{
// Convert to binary
$bin = decbin($x);
$bin = substr(str_repeat(0,$numbits),0,$numbits - strlen($bin)).$bin;
// Split into x 4-bits long
$rtnval = '';
for($x = 0; $x < $numbits/4; $x++)
{
$rtnval .= substr($bin,$x*4,4);
}
// Get rid of first space.
return ltrim($rtnval);
}
?>