Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: ANS TC Magnet for Division Message-ID: <679.UUL1.3#5129@willett.UUCP> Date: 19 Mar 90 02:52:40 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 44 Category 10, Topic 17 Message 60 Sun Mar 18, 1990 R.BERKEY [Robert] at 07:05 PST To: Wil Baden Re: Languages with floored or positive-divisor-floored remainder operators I've found some old notes once upon a time posted on the ECFB, and for a while they were in the GEnie library. A. P. Chang published a language survey in SIGPLAN Notices, V20 #4, April 1985. He reported that Ada, Modula, Pascal Standard, APL, and PL/1 include a remainder operator that, like Forth-83: -29 mod 5 = 1 Ada also requires the functionality of symmetry. Ada and APL are also like Forth-83 in specifying: 29 mod -5 = -1 which is consistent with the mathematical definition of mod as given by Knuth (except for division by zero). Tom Almy in ECFB Standard's Conference Msg. 2383 mentions, "Smalltalk, which (has) functions for both rounding methods". Knuth, p. 38, in Volume 1 of the _Art of Computer Programming_, shows the definition of mod as follows: x mod y = x - y(floor(x/y)) if y <> 0; x mod 0 = x So between 1968 and 1989 (in _Concrete Mathematics_), Knuth has compromised a bit on the case involving x mod 0. Some languages (FORTRAN and BASIC) and floating point processors provide the floor function, perhaps under the name INT, which as shown in Knuth's formula can be used to generate integer flooring. Robert ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'