ARNESI

Messing with numbers 

(defun parse-ieee-double (u64)
  "Given an IEEE 64 bit double representeted as an integer (ie a
  sequence of 64 bytes), return the coressponding double value"
  (* (expt -1 (ldb (byte 1 63) u64))
     (expt 2 (- (ldb (byte 11 52) u64) 1023))
     (1+ (float (loop for i from 51 downto 0
                      for n = 2 then (* 2 n)
                      for frac = (* (/ n) (ldb (byte 1 i) u64))
                      sum frac)))))
(defun parse-float (string
                    &key (start 0) (end nil) (radix 10)
                         (type 'single-float ))
  (let* ((*read-eval* nil)
	 (*read-base* radix)
	 (value (read-from-string string nil nil
                                  :start start :end end)))
    (if (and value (numberp value))
	(coerce value type)
	nil)))
(define-modify-macro mulf (delta)
  *
  "SETF NUM to the result of (* NUM B).")
(define-modify-macro divf (delta)
  /
  "SETF NUM to the result of (/ NUM B).")
(define-modify-macro minf (other)
  (lambda (current other)
    (if (< other current)
        other
        current))
  "Sets the place to new-value if new-value is #'< the current value")
(define-modify-macro maxf (other)
  (lambda (current other)
    (if (> other current)
        other
        current))
  "Sets the place to new-value if new-value is #'> the current value")
(defun map-range (lambda min max &optional (step 1))
  (loop for i from min upto max by step
     collect (funcall lambda i)))
(defmacro do-range ((index &optional min max step return-value)
                    &body body)
  (assert (or min max)
          (min max)
          "Must specify at least MIN or MAX")
  `(loop
      for ,index ,@(when min `(from ,min))
                 ,@(when max `(upto ,max))
                 ,@(when step `(by ,step))
      do (progn ,@body)
      finally (return ,return-value)))
(defun 10^ (x)
  (expt 10 x))