Skip to content

toInteger()

Evgheniy Kovaliov edited this page May 10, 2023 · 1 revision

toInteger(ip)

Description

Method that allows you convert ip address to integer id.
Ip address must be correct. (see validation)

Contract

Parameters:

  • ip: string — ip address to convert.

Return:

  • number
Exceptions

Invalide ip address!:

  • entered argument is not a correct ip address.
Usage
ipv4.toInteger('123.123.123.123'); // 2071690107
ipv4.toInteger('0.0.0.0'); // 0
ipv4.toInteger('255.255.255.255'); // 4294967295
ipv4.toInteger('1.2.3.4'); // 16909060
ipv4.toInteger('0.0.0.1'); // 1
ipv4.toInteger('1.0.0.0'); // 16777216
ipv4.toInteger('100.200.100.200'); // 1690854600

ipv4.toInteger('10.255.255.256'); // Error: Invalide ip address!
ipv4.toInteger('10.0.0.one'); // Error: Invalide ip address!
ipv4.toInteger('127.0.0.0.10'); // Error: Invalide ip address!
  • Is used in other methods.

MAIN PAGE

See all methods documentation:

For ip version 4

For ip version 6

Clone this wiki locally