Subject: Re: Q: (LispWorks) speed issue
From: Erik Naggum <>
Date: Wed, 13 Mar 2002 18:12:42 GMT
Newsgroups: comp.lang.lisp
Message-ID: <>

* Nicolas Neuss
| An even simpler possibility is to use floating point operations for
| semi-long integers.  Try the following:
| (defun tt (nn)
|   (declare (optimize (speed 3) (safety 0)))
|   (loop for k of-type double-float below (float nn 1.0d0) do
| 	nil))
| (time (tt 100000000))

  Very good advice, only make sure that k and (1- k) are different, i.e.,
  that you use fewer bits than the precision of the floating point format.
  (float-precision 1d0) returns that number.

  Of course, this works best when double-floats are not passed around,
  otherwise, they need to be boxed and cons like mad.  It _should_ have
  been equally efficient with bignums, methinks.  Oh, well.

  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.