def left(i,n) s = i.to_s(2) n.times{s += "0"} s.to_i(2) end def right(i,n) s = i.to_s(2) n.times{s.slice!(-1,1)} s.to_i(2) end p (left 2,1)==2<<1 p (right 2,1)==2>>1 p (left 2,2)==2<<2 p (right 2,2)==2>>2 p (left 2,3)==2<<3 p (right 2,3)==2>>3
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |