Function: erc-decimal-to-ip

erc-decimal-to-ip is a byte-compiled function defined in erc-dcc.el.gz.

Signature

(erc-decimal-to-ip DEC)

Documentation

Convert a decimal representation DEC to an IP address.

The result is also a string.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-dcc.el.gz
(defun erc-decimal-to-ip (dec)
  "Convert a decimal representation DEC to an IP address.
The result is also a string."
  (when (stringp dec)
    (setq dec (string-to-number (concat dec ".0"))))
  (let* ((first (floor (/ dec 16777216.0)))
         (first-rest (- dec (* first 16777216.0)))
         (second (floor (/ first-rest 65536.0)))
         (second-rest (- first-rest (* second 65536.0)))
         (third (floor (/ second-rest 256.0)))
         (third-rest (- second-rest (* third 256.0)))
         (fourth (floor third-rest)))
    (format "%s.%s.%s.%s" first second third fourth)))