Skip to main content

toNumber

toNumber(ipAddr: IpAddress) : Number

Returns the numeric value corresponding to an IPv4 address. For example, toNumber(ipAddress("0.0.1.2")) is 258.

caution

Note that this can only be applied to an IPv4 address.

The ipv4Address function and the toNumber are inverses: toNumber(ip) == num is true exactly when ip == ipv4Address(num) is true, for ip an IPv4 address and num an integer in 0..2^32-1. For example:

  • ipv4Address(toNumber(ipAddress("1.2.3.4"))) == ipAddress("1.2.3.4")
  • toNumber(ipv4Address(1234))) == 1234

See also

Types

Functions