Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.szaf.org!news.gnuher.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: Bernd Paysan Newsgroups: comp.lang.forth Subject: Re: PICK changed from 1-based to 0-based? Date: Sun, 05 Jan 2014 21:14:11 +0100 Organization: 1&1 Internet AG Lines: 40 Message-ID: References: <7xvby8f6md.fsf@ruckus.brouhaha.com> <52bff96e$0$2861$e4fe514c@news2.news.xs4all.nl> <52c05cfd$0$2919$e4fe514c@news2.news.xs4all.nl> <52c42581$0$2875$e4fe514c@news2.news.xs4all.nl> <2014Jan3.152213@mips.complang.tuwien.ac.at> <52c9431d.1036475884@news.demon.co.uk> <6ZGdnef-1Pt70VTPnZ2dnUVZ_qGdnZ2d@supernews.com> <78udnYX5-5y7HlTPnZ2dnUVZ_qWdnZ2d@supernews.com> NNTP-Posting-Host: p5dcd6c86.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: online.de 1388952851 18963 93.205.108.134 (5 Jan 2014 20:14:11 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Sun, 5 Jan 2014 20:14:11 +0000 (UTC) User-Agent: KNode/4.11.3 Xref: csiph.com comp.lang.forth:27692 Andrew Haley wrote: > On x86 I imagine you're right, but not always: it is possible to do > symmetric division (in hardware) at the same speed as unsigned. SRT > division can be implemented this way. It might be possible, but who does it? Intel has some tradition with SRT (famous FDIV bug), so they could. You could use the same circuit for the non-restoring version of SRT to do both signed and unsigned division by spending an extra bit - then both signed and unsigned numbers can be expanded to fit into the same representation. However, SRT is itself agnostic to floored or symmetric division, because it can produce negative or positive remainders, independent of the actual inputs, so the last step in SRT is to adjust the remainder to the chosen rounding method. That's because SRT will always produce an odd quotient (a result of the representation), and the remainder is in the range [-d..d[. If you want to try, here's it: \ non-restoring division : nr/mod ( d n -- nq nr ) 0 8 cells 0 DO >r >r dup 0< IF d2* r@ + r> r> 2* ELSE d2* r@ - r> r> 2* 1+ THEN LOOP >r drop nip r> 2* 1+ swap ; srt uses essentially the same algorithm, but it is less precise, so the final correction is a bit larger - you might end up with two correction steps instead of just one. -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/