Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!uunet!zephyr.ens.tek.com!tektronix!percy!m2xenix!puddle!f503.n151.z1.fidonet.org!Rw.Hutchinson From: Rw.Hutchinson@f503.n151.z1.fidonet.org (Rw Hutchinson) Newsgroups: comp.lang.modula2 Subject: Why no ** operator in Modula2? Message-ID: <313.2843FB3F@puddle.fidonet.org> Date: 29 May 91 00:33:00 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 1:151/503 - Quantum Tech, Chapel Hill NC Lines: 15 In a message to All <27 May 91 13:09> Debora Weber-Wulff wrote: DW> The question came up in class today: Why is there no ** or ^ DW> (x to the nth power) operator in standard Modula2? DW> We checked the 3 books we use in class and found no mention of DW> why this is missing. Some textbooks state that (in Pascal, and I see no reason for there to be a change in reason) the reason is to make the programmer think twice before using such an "expensive" (in computer resources) function without thinking, when it may be unnecessary. The issue is whether the n (as in nth. power) is an integer, or real. If n is an integer, then a succession of multiplications (or squarings, or whatever for efficiency [see Knuth, Vol. 2]) can yield a fairly efficient implementation, whereas if n is real, then the logarithm is called for, which is a transcendental function and rather more work to compute. -- uucp: uunet!m2xenix!puddle!151!503!Rw.Hutchinson Internet: Rw.Hutchinson@f503.n151.z1.fidonet.org