75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/sjcl/bit_array.rb', line 75
def self.shiftRight(a, shift, carry=0, out=[])
out = out.dup
last2 = 0
while shift >= 32
out.push(carry)
carry = 0
shift -= 32
end
if (shift === 0)
return out.concat(a)
end
a.length.times do |i|
out.push(carry | (a[i] & 0xFFFFFFFF)>>shift)
carry = (a[i] << (32-shift) & 0xFFFFFFFF)
end
last2 = a.length > 0 ? a[a.length-1] : 0
shift2 = getPartial(last2)
out.push(partial((shift+shift2) & 31, (shift + shift2 > 32) ? carry : out.pop(),1))
return out;
end
|