Date: Sun, 23 Jan 2022 14:48:14 +0000 (GMT) Message-ID: <1597269202.107036.1642949294997@9c5033e110b2> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_107035_1738633153.1642949294997" ------=_Part_107035_1738633153.1642949294997 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html IPFROMINT Function

IPFROMINT Function

Computes a four-octet internet protocol (IP) address from a 32= -bit integer input.

Source value must be a valid integer within the range specified by= the formula below. A valid IPv4 address is in the following fo= rmat:

=20
aaa.bbb.cc=
c.ddd
=20

NOTE: IPv6 addresses are not supported.

The formula used to compute the integer equivalent of an IP address is t= he following:

(aaa * 2563) + (bbb * 2562) + (ccc * 256) + = (ddd)

So, the formula to compute this IP address is the following:

=20 =20 =20 =20 =20 =20
Input aaa bbb ccc ddd
X

aaa =3D floor(Input / (256= 3 ))

remainderA =3D Input - aaa

bbb =3D floor(remainderA / (256= 2 ))

remainderB =3D remainderA - bbb

ccc =3D floor(remainderB / 256)=

remainderC =3D remainderB - ccc

ddd =3D remainderC

Output value:

Output =3D aaa + '.' + bbb + '.' + ccc + '= .' + ddd

Basic Usage=

Numeric literal example:

=20

derive type:single value: IPFR= OMINT('16909060' ) as:'ip_addr'

Output: Generates a column containing the IP address 1.2.3.4.

Column reference example:

=20

derive type:single value: IPFR= OMINT(IpInt) as: 'ip_addr'

Output: Generates the new ip_addr col= umn containing the values of the IpInt column c= onverted to an IP address value.

Sy= ntax and Arguments

=20

derive type:single value: IPFR= OMINT(column_int)

=20 =20 =20 =20 =20
Argument Required? Data Type Description
column_int Y string or integer Name of column or integer literal that is to be = converted to an IP address value

For more information on syntax standards, see Language Documentation Syntax Note= s.

column_int

Name of the column or integer literal whose values are used to compute t= he equivalent IP address value.

• Missing input values generate missing results.
• Multiple columns and wildcards are not supported.

Usage Notes:

=20 =20 =20 =20
Required? Data Type Example Value
Yes Integer literal or column reference 16909060

Examples

Example -= Convert IP addresses to integers

This examples illustrates how you can convert IP addresses to numeric va= lues for purposes of comparison and sorting. This example illustrates the f= ollowing functions:

• IPTOINT - converts an IP address to an integer value accor= ding to a formula. See IPTOINT F= unction.
• IPFROMINT - converts an integer value back to an IP addres= s according to formula. See IP= FROMINT Function.

Source:

=20 =20
192.0.0.1
10.10.10.10
1.2.3.4
1.2.3
http://12.13.14.15
https://16.17.18.19

Transform:

When the above data is imported, the application initially types the col= umn as URL values, due to the presence of the http:// and https:// protocol identifiers. Select the IP Address data type for= the column. The last three values are listed as mismatched values. You can= fix the issues with the last two entries by applying the following transfo= rm, which matches on both http:// and https:// st= rings:

=20

NOTE: The %? Trifacta=C2=AE pattern matches zero or one time on any character, = which enables the matching on both variants of the protocol identifier.

Now, only the 1.2.3 value is mismatched. Perhaps you know t= hat there is a missing zero at the end of it. To add it back, you can do th= e following:

=20

replace col: IpAddr on: `1.2.3{end}` with: '1.2.3= .0' global: true

All values in the column should be valid for the IP Address data type. T= o convert these values to their integer equivalents:

=20

derive type:single value:IPTOINT(IpA= ddr) as:'ip_as_int'

You can now manipulate the data based on this numeric key. To convert th= e integer values back to IP addresses for checking purposes, use the follow= ing:

=20

derive type:single value:IPFROMINT(i= p_as_int) as:'ip_check'

Results:

X ip_as_int ip_check
192.0.0.1 3221225473 192.0.0.1
10.10.10.10 168430090 10.10.10.10
1.2.3.4 16909060 1.2.3.4
1.2.3.0 16909056 1.2.3.0
12.13.14.15 202182159 12.13.14.15
16.17.18.19 269554195 16.17.18.19

=20
=20