(in-package :cl-user) (defun single-float-uint32 (x) (rlet ((a :single-float x)) (%get-unsigned-long a 0))) (defun uint32-single-float (x) (rlet ((a (:unsigned 32) x)) (%get-single-float a 0))) (defun rsqrt (number) (let ((x/2 (* number 0.5f0)) (y (uint32-single-float (- #x5f3759df (ash (single-float-uint32 number) -1))))) (setf y (* y (- 1.5f0 (* x/2 y y)))) ;; (setf y (* y (- 1.5f0 (* x/2 y y)))) y))