title: Converting negative number to IP address python
body: <p>and i am trying to convert long numbers to IP address but python doesnt allow me to convert -ve values to long. Below are my functions, can anyone please help?</p>
  <h1>Convert ip addess from string to integer</h1>
  <pre><code>def get_ip_address_int(ip_address):
      return struct.unpack(&quot;!L&quot;, socket.inet_aton(ip_address))[0]
  
  # Convert ip adress from integer to string
  def get_ip_address_str(ip_address):
      return socket.inet_ntoa(struct.pack('!L',ip_address))
  </code></pre>
  <p>ip_address = -1277278613</p>
  <p>Thanks a lot in advance.</p>