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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bitwiseCalc +5 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d3103a5fd687a81612d73de708b9c568d3ebdf8
4
- data.tar.gz: db05fbce25c5a9505ae41c59aabd1239b963dc2c
3
+ metadata.gz: 3c92206900bafe376ee152d767963483ce86382a
4
+ data.tar.gz: 7cb0f12e54fb72c8ebf787bb8a203f9a4c737948
5
5
  SHA512:
6
- metadata.gz: 364294f69ce190b3f6961e19a9dbd3b7d738eceea8d3e0121f82a8c06d626641aac45cc583ad83a1e39a584d8dea5d8faf865791f435f42c613936f1074d5bbd
7
- data.tar.gz: a3e586b78e01d2038ce92df9921669dfd24fd03c9550fef54c94f0cbe40491024291f149efc8f138b20a18449b421f93e292b3257f17795a2642b5125518e903
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-08 20:39:01
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 (i == 0) ? @x = a.to_i: @y = a.to_i
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 current elem to next elem
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 elem, make next elem previously saved elem
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 #refresh var
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.5
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-08 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize