-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
52 lines (38 loc) · 1.66 KB
/
README
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
================================================================================================
powerof2.cpp
Finds if the input number is a power of 2.
./powerof2 1024
Input: 1024
Input (base 2): 0000000000000000000000000000000000000000000000000000010000000000
Input-1 (base 2): 0000000000000000000000000000000000000000000000000000001111111111
Input & (Input -1), (base 2): 0000000000000000000000000000000000000000000000000000000000000000
result: 0
True
./powerof2 1023
Input: 1023
Input (base 2): 0000000000000000000000000000000000000000000000000000001111111111
Input-1 (base 2): 0000000000000000000000000000000000000000000000000000001111111110
Input & (Input -1), (base 2): 0000000000000000000000000000000000000000000000000000001111111110
result: 1022
False
================================================================================================
bitpos.cpp
Reads a decimal number and outputs the binary form and the set bit position numbers.
./bitpos 1024
Input : 1024
Binary: 0000000000000000000000000000000000000000000000000000010000000000
Bit position: 10 is set
./bitpos 4294967298
Input : 4294967298
Binary: 0000000000000000000000000000000100000000000000000000000000000010
Bit position: 1 is set
Bit position: 32 is set
================================================================================================
bitpostodec.cpp
Reads multiple decimal numbers, sets those bit positions in a 64 bit integer and
returns the decimal equivalent.
./bitpostodec 10
Value: 1024
./bitpostodec 32 1
Value: 4294967298
================================================================================================