bitwiseCalc 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bitwiseCalc +5 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c92206900bafe376ee152d767963483ce86382a
|
4
|
+
data.tar.gz: 7cb0f12e54fb72c8ebf787bb8a203f9a4c737948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf155916dcc2474d9009e908053a404415e9c5436e9582083478d1d97930dada91228ef2563c58e3be56adcca54f01ee9945633b3de89793ea249be15474bb3
|
7
|
+
data.tar.gz: c9fc8eeecf0345d825f51a9ee49efac3e95e0074f11ac02babb10a38fb0653def7d994b44c75bb585c0b9a4b6c80b3b0492e1e2494c7a964e1026450864a56d4
|
data/lib/bitwiseCalc
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# @Email: vargash1@wit.edu
|
5
5
|
# @Date: 2015-02-23 10:23:20
|
6
6
|
# @Last Modified by: vargash1
|
7
|
-
# @Last Modified time: 2015-05-
|
7
|
+
# @Last Modified time: 2015-05-10 12:49:45
|
8
8
|
require 'colorize'
|
9
9
|
class BoolCalc
|
10
10
|
def print_all_radix(num)
|
@@ -54,7 +54,6 @@ class BoolCalc
|
|
54
54
|
end
|
55
55
|
#not and rad require just one number argument
|
56
56
|
#if operation is not either and y is nil then we have a problem...
|
57
|
-
#every operation also requires at least 1 number
|
58
57
|
operation_restriction = (@operation != "NOT" && @operation != "RAD")
|
59
58
|
if ((operation_restriction && @y == nil) || (@x == nil))
|
60
59
|
abort("ERROR, MISSING NUMBER(s)".red)
|
@@ -62,7 +61,6 @@ class BoolCalc
|
|
62
61
|
end
|
63
62
|
def parse_args()
|
64
63
|
ops = ['NOT','SHR','SHL','AND','OR','XOR','RAD','ROL','ROR']
|
65
|
-
i = 0
|
66
64
|
if (ARGV.length == 0 || (ARGV[0].upcase) == "-H")
|
67
65
|
print_help()
|
68
66
|
exit
|
@@ -79,8 +77,7 @@ class BoolCalc
|
|
79
77
|
#if ARGV[a] is a number, save it.
|
80
78
|
#also keep track of how many numbers we have read
|
81
79
|
when (is_number(a.to_i))
|
82
|
-
if (
|
83
|
-
i += 1
|
80
|
+
if (@x == nil) ? @x = a.to_i: @y = a.to_i
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|
@@ -134,30 +131,27 @@ class BoolCalc
|
|
134
131
|
puts
|
135
132
|
end
|
136
133
|
#converts an integer to a binary array
|
137
|
-
#used for rotating
|
138
134
|
def int_to_binary_arr()
|
139
135
|
@bit64_array_x = []
|
140
136
|
63.downto(0) do |n|
|
141
137
|
@bit64_array_x << @x[n]
|
142
138
|
end
|
143
139
|
end
|
144
|
-
#for rotating we only need 64 bit verisions
|
145
140
|
def ror()
|
146
141
|
for i in 1..@y
|
147
142
|
#save least significant bit(end of array)
|
148
143
|
lsb = @bit64_array_x[-1]
|
149
|
-
#since we only want to change all elems besides the last
|
150
144
|
for j in 0..(@bit64_array_x.length-2)
|
151
145
|
if j == 0
|
152
146
|
#save next elem(right shift)
|
153
|
-
#assign
|
147
|
+
#assign next element in the array to the current element
|
154
148
|
tmp1 = @bit64_array_x[j+1]
|
155
149
|
@bit64_array_x[j+1] = @bit64_array_x[j]
|
156
150
|
end
|
157
|
-
#save next
|
151
|
+
#save next element, make next element previously saved elem
|
158
152
|
tmp2 = @bit64_array_x[j+1]
|
159
153
|
@bit64_array_x[j+1] = tmp1
|
160
|
-
tmp1 = tmp2
|
154
|
+
tmp1 = tmp2
|
161
155
|
end
|
162
156
|
#assign least significant bit(end of array) to head of array
|
163
157
|
@bit64_array_x[0] = lsb
|
@@ -169,7 +163,6 @@ class BoolCalc
|
|
169
163
|
msb = @bit64_array_x[0]
|
170
164
|
for j in 0..(@bit64_array_x.length-2)
|
171
165
|
#assign next element in array to current element in array
|
172
|
-
#no need to save as no data is lost(msb will save first array elem)
|
173
166
|
@bit64_array_x[j] = @bit64_array_x[j+1]
|
174
167
|
end
|
175
168
|
#assign most significant bit to tail
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitwiseCalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hector Vargas
|
8
8
|
autorequire:
|
9
9
|
bindir: lib
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|