ANEW --/ROUND-- \ Wil Baden 2002-04-10 \ ******************************************************************* \ * * \ * Wil Baden 2003-01-29 * \ * * \ * Rounded Division * \ * * \ * /ROUND ( num +den -- quot ) * \ * Divide and round to the nearest integer. If the exact * \ * result is exactly halfway between two integers, the even * \ * result is chosen. * \ * * \ ******************************************************************* \ I've used rounded division only with positive divisors to reduce \ bias in arithmetic means. My code needs the remainder to be \ non-negative. This says that floored division should be used with \ positive divisors. : /ROUND ( num +den -- quot ) >R S>D R@ FM/MOD SWAP 2* over 1 AND + R> > 1 AND + ; \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\