CFLib.org – Common Function Library Project

IPDottedDecimal2IPAddress(ipValue)

Last updated September 27, 2002

author

Jonathan Pickard

Version: 1 | Requires: CF5 | Library: NetLib

Description:
Use IPDottedDecimal2IPAddress to convert an IP dotted decimal value to an IP address string. Storing decimal values in a database and making comparisons with them is more efficient than using IP address strings.

Return Values:
Returns a string.

Example:

<cfoutput>
#IPDottedDecimal2IPAddress( -1062731769)#
</cfoutput>

Parameters:

Name Description Required
ipValue Dotted decimal value of IP address. Yes

Full UDF Source:

/**
 * Converts a 32-bit dotted decimal IP number to an IP address.
 * 
 * @param ipValue      Dotted decimal value of IP address. (Required)
 * @return Returns a string. 
 * @author Jonathan Pickard (j_pickard@hotmail.com) 
 * @version 1, September 27, 2002 
 */
function IPDottedDecimal2IPAddress( ipvalue ) {
    var ipAddress = "";
    var lBitMasks = "24,16,8,0";
    var i = 1;

    for ( ; i LTE 4; i = i + 1 )
    {
        ipAddress = ipAddress & "." & BitMaskRead( ipvalue, ListGetAt( lBitMasks, i ), 8 );
    }
    ipAddress = Right( ipAddress, Len( ipAddress ) - 1 );

    return ipAddress;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson