From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.esat.net!nslave.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader3.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Q: (LispWorks) speed issue References: <3c8ddbcc$1_2@news.meganetnews.com> <3c8e3ce1$1_5@news.meganetnews.com> <87vgc069gh.fsf_-_@ortler.iwr.uni-heidelberg.de> Mail-Copies-To: never From: Erik Naggum Message-ID: <3225031973116929@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 23 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 13 Mar 2002 18:12:42 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader3.kpnqwest.net 1016043162 193.71.199.50 (Wed, 13 Mar 2002 19:12:42 MET) NNTP-Posting-Date: Wed, 13 Mar 2002 19:12:42 MET Xref: archiver1.google.com comp.lang.lisp:28776 * 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.