There are generally two formats for storing IP addresses in the IP address database, one is dotted decimal format (192.168.1.1), and the other is digital format (3232235777). In applications, it is often necessary to convert between these two formats.
To solve this problem, I implemented a quick method for converting between the two in the exnet extension package:
Example of use:
So how do you convert a dotted decimal IP address into a number? An IPv4 address has 4 bytes and looks like this:
Each byte represents the range:
General formula: b4<<24 | b3<<16 | b2<<16 | b1 For example, 222.173.108.86 Conversion method: 222<<24 | 173<<16 | 108<<8 | 86 = 3735907414 For example, 1.0.1.1 Conversion method: 1<<24 | 0<<16 | 1<<8 | 1 = 16777473 The implementation in exnet is as follows:
Just flip the logic of converting a numeric value to a string. This is implemented in exnet as follows:
|
<<: When porting your number to another network, operators should first change their service mindset
[[416937]] Experimental requirements ISP-1 and IS...
The latest news shows that my country has built a...
On December 3-4, the 2019 China Data and Storage ...
Enterprise IT can't keep up with the growing ...
At the beginning of 2020, the COVID-19 epidemic w...
RackNerd has launched a special package for Memor...
Maxthon Hosting has launched a new Los Angeles Tr...
iwebfusion (iWFHosting) recently launched cluster...
On February 1, the Ministry of Industry and Infor...
[51CTO.com original article] The Global Software ...
"Reuters reported that Huawei plans to incre...
OneTechCloud is offering a 10% discount on monthl...
[[397123]] In this article, we will explain what ...
While 5G has the potential to open up many exciti...
A few days ago, the blog shared the information t...