[ytti@ytti.fi ~]% pry [1] pry(main)> addr = 1862270976 => 1862270976 [2] pry(main)> mask = 4294967040 => 4294967040 [3] pry(main)> addr.to_s(2) => "1101111000000000000000000000000" [4] pry(main)> mask.to_s(2) => "11111111111111111111111100000000" [5] pry(main)> (addr | (mask ^ (2**32-1))).to_s(2) => "1101111000000000000000011111111" [6] pry(main)> (addr | ~mask).to_s(2) => "-10010000111111111111111100000001" [7] pry(main)>ß