All Products
Search
Document Center

MaxCompute:NET_IPV4_TO_INT64

Last Updated:Oct 21, 2025

The NET_IPV4_TO_INT64 function converts an IPv4 address in binary format to a BIGINT value.

Syntax

BIGINT NET_IPV4_TO_INT64(BINARY <addr>)

Parameters

addr: Required. An IPv4 address of the BINARY data type. This function does not support IPv6 addresses.

Return value

Returns a BIGINT value that represents the IP address. The following rules apply:

  • If the input addr is not a valid IPv4 address in BINARY format, the function returns an error.

  • If the input addr is NULL, the function returns NULL.

Note

The least significant bits of the IP address are stored as the least significant bits of the returned integer. For example, 1 represents 0.0.0.1, and 511 represents 0.0.1.255. The output is in the range of [0, 4294967295].

Examples

  • Example 1: Use this function with the NET_SAFE_IP_FROM_STRING function. The NET_SAFE_IP_FROM_STRING function converts an IPv4 address from STRING format to BINARY format. Then, the NET_IPV4_TO_INT64 function converts the binary result to a BIGINT value.

    -- Returns 808530483
    SELECT NET_IPV4_TO_INT64(NET_SAFE_IP_FROM_STRING('48.49.50.51'));
    
    -- Returns 1
    SELECT NET_IPV4_TO_INT64(NET_SAFE_IP_FROM_STRING('0.0.0.1'));
    
    -- Returns 511
    SELECT NET_IPV4_TO_INT64(NET_SAFE_IP_FROM_STRING('0.0.1.255'));
  • Example 2: If the input value is NULL, the function returns NULL.

    -- Returns NULL
    SELECT NET_IPV4_TO_INT64(NULL);

Related functions

NET_IPV4_TO_INT64 is a network function. For more information about network functions, see Network functions.