class Integer
Constants
- SHIFT_MAX_BITS
NOTE: To restrict the bit-shift width.
Public Instance Methods
arithmetic_right_shift(rhs)
click to toggle source
# File lib/adlint/prelude.rb, line 114 def arithmetic_right_shift(rhs) rhs < 0 ? self : self >> [rhs, SHIFT_MAX_BITS].min end
left_shift(rhs)
click to toggle source
# File lib/adlint/prelude.rb, line 118 def left_shift(rhs) rhs < 0 ? self : self << [rhs, SHIFT_MAX_BITS].min end
logical_right_shift(rhs)
click to toggle source
# File lib/adlint/prelude.rb, line 103 def logical_right_shift(rhs) return self if rhs < 0 bits = to_s(2) shift_width = [rhs, SHIFT_MAX_BITS].min if bits.length < shift_width 0 else ("0" * shift_width + bits[0..-(shift_width + 1)]).to_i(2) end end