C语言ip地址转换成十六进制,将IP地址转换为十六进制

有时你会看到它的格式是这样的HEX IP地址。

0xC0.0xA8.0x2A.0x48

这里是我如何做到这一点在我的头上,因为我不擅长与大的数字,因为十六进制是基于16下图是DEC左和HEX的权利。

0 = 0

1 = 1

2 = 2

3 = 3

4 = 4

5 = 5

6 = 6

7 = 7

8 = 8

9 = 9

10 = A

11 = B

12 = C

13 = D

14 = E

15 = F

然后,一旦你有图表记忆,这只是基本的数学

192 = C0 = (192/16) = 12.0 = take the remainder (0 x 16) = 0 convert it to Hex (0)

then take the result (12) divide it by 16 (12/16) and if it's less then 1 then just

covert the remainder to hex 12 = C then add it up backwards for C0

168 = A8 = (168/16) = 10.8 = he remainder (.8 x 16) = 12.8 convert it to hex (A) then

take the result (12) divide it by 16 (12/16) and if it's less then 1 then just covert

the remainder to hex 0 = 0 then add it up backwards for 0A8 or A8

42 = 2A = (42/16) = 2.625 = The remainder (.625 x 16) = 10 convert it to hex (A) then

take the result (2) divide it by 16 (2/16) and if it's less then 1 then just covert the

remainder to hex 2 = 2 then add it up backwards for 2A

72 = 48 = Your turn

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值