some tricks about 2s complementary about mask address

来源:互联网 发布:zepto.js 左右滑动 编辑:程序博客网 时间:2024/05/29 12:41

some trick about the mack on calculation

1.we can just calulate the last bit that we needeg: 206.34.221.33/7we can just compute the last (8-7) bit on the first byte206%2==0 so last bit equals 0;eg2: 206.34.221.35/20

we can anology the first one we just compute previously
just compute the last (8*3-20) bit one the fourth byte

221%2==1. so we donote    1110%2==0 so we donote     0155%2==1 so we donote      10127%2==1 so we donote      110113%2==1 so we donote      11101

in practice ,we just need the last fourth bits ,to make clearly,we calculate the last fourth bits
so the mask is 206.34.(221-13=208).0

hope you can enjoy it

give the length of the mask ,calculate the mask addresseg: length=11we can split 11 equals 8 plus 3the first 8 bits are abvious ,i.e. 255the following 3 bits .we can think it like this way.(255-(2^5-1))=224.so the problem can be solved easily.
so if the length is 18we can easily write the mask address like this way.i.e.,the answer is 255.255.192.0
0 0
原创粉丝点击