import socket
import struct


def long2ip(n):
    """Calculate the dotted-quad string representation of a long integer

    :param n: IP address as a long value
    :return: IP address as a dotted-quad string
    """
    return socket.inet_ntoa(struct.pack('!L', n))