some tricks about 2s complementary about mask address

some trick about the mack on calculation

1.we can just calulate the last bit that we need
eg: 206.34.221.33/7
we can just compute the last (8-7) bit on the first byte
206%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    1
110%2==0 so we donote     01
55%2==1 so we donote      101
27%2==1 so we donote      1101
13%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 address
eg: length=11
we can split 11 equals 8 plus 3
the first 8 bits are abvious ,i.e. 255
the 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 18
we can easily write the mask address like this way.
i.e.,the answer is 255.255.192.0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值