-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount.php
More file actions
51 lines (43 loc) · 1.21 KB
/
count.php
File metadata and controls
51 lines (43 loc) · 1.21 KB
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
<?php
// The processor class
require_once 'Processor.php';
// Input array of booleans
$input1 = [
'1' => false,
'2' => true
];
// Input array of booleans to be sum up by $input1
$input2 = [
'1' => false,
'2' => true
];
// Using the processor class to add $input2 by $input1 and get a binary string
Processor::multiplier2bit(array_values($input1), array_values($input2), $binString);
// Displays the result on screen
echo 'Output add -- binString: ' . $binString . PHP_EOL;
echo 'Output add -- Number: ' . bindec($binString) . PHP_EOL;
// Input array of booleans
$input1 = [
'1' => false,
'2' => false,
'4' => false,
'8' => false,
'16' => false,
'32' => true,
'64' => false,
];
// Input array of booleans to be sum up by $input1
$input2 = [
'1' => false,
'2' => true,
'4' => true,
'8' => true,
'16' => false,
'32' => false,
'64' => false,
];
// Using the processor class to add $input2 by $input1 and get a binary string
Processor::subtract(array_values($input1), array_values($input2), $binString);
// Displays the result on screen
echo 'Output subtract -- binString: ' . $binString . PHP_EOL;
echo 'Output subtract -- Number: ' . bindec($binString) . PHP_EOL;