Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!SUN.COM!wmb From: wmb@SUN.COM Newsgroups: comp.lang.forth Subject: Re: Mathematical routines Message-ID: <9001161901.AA02061@jade.berkeley.edu> Date: 15 Jan 90 00:12:48 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Forth Interest Group International List Organization: The Internet Lines: 17 >Does anyone out there know how to do this: I want to compute s = a0 * b0 + >a1 * b1 + ... + an * bn where n is to be determined at run time, and could be >as large as 300, and the ai, bi are unsigned byte quantities, and s is to be >scaled to an unsigned byte quantity. Also, I don't want to do it in floating >point. It seems this should be pretty straight-forward, but I keep getting >myself confused. I think Forth needs a word to detect when CARRY is set. 2 ways of detecting carry: 1) Perform the addition in double precision and look for a 1 in the high word. 2) : carry? ( a b -- flag ) negate u>= ; Flag is true if the unsigned addition of a and b would generate a carry. This only works for 2's complement machines. Mitch