Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!rochester!ritcv!ccivax!rb From: rb@ccivax.UUCP (rex ballard) Newsgroups: net.lang.c,net.arch Subject: Integer division Message-ID: <387@ccivax.UUCP> Date: Mon, 10-Feb-86 22:37:37 EST Article-I.D.: ccivax.387 Posted: Mon Feb 10 22:37:37 1986 Date-Received: Fri, 14-Feb-86 05:53:46 EST References: <731@abic.UUCP> <4947@alice.uUCp> Reply-To: rb@ccivax.UUCP (What's in a name ?) Organization: CCI Telephony Systems Group, Rochester NY Lines: 27 Xref: linus net.lang.c:7306 net.arch:2317 Summary: FORTH-83 better? As I recall, FORTH-83 has adopted the 'theorists' approach. so that A B SWAP OVER /MOD ROT * + gives the original value of A translated that gives A B SWAP ( Stack = B A ) OVER ( Stack = B A B ) /MOD ( Stack = A%B A/B B ) (A/B is floored) ROT ( Stack = A/B B A%B ) * ( Stack = (A/B)*B A%B ) + ( Stack = (A/B)*B+A%B ) (=A) This was a deliberate break from FORTH-79 which would have required the 'twiddle test'. Appearently, most applications either were using the unsigned versions, the positive case, or had rewritten the primitive. the example (taken from the draft standard of May 83) dividend divisor remainder quotient 10 7 3 1 -10 7 4 -2 10 -7 -4 -2 -10 -7 -3 1 Is this any better? I guess religion (because thats the way we always do it) isn't everything.