From 8727738645760827188
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,9a5d91576ea14293
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,42ca30940288d269
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-02-29 16:34:53 PST
Xref: sparky comp.lang.c++:5414 comp.std.c++:250
Path: sparky!uunet!wupost!uwm.edu!linac!att!att!andante!alice!ark
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Re: X to the Y power, how?
Message-ID: <22305@alice.att.com>
Date: 29 Feb 92 15:58:37 GMT
Article-I.D.: alice.22305
References: <50175@hydra.gatech.EDU> <1992Feb27.135250.25403@ux1.cso.uiuc.edu> <1992Feb27.223558.276@rice.edu> <22292@alice.att.com> <omci1INN8np@agate.berkeley.edu>
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Liberty Corner NJ
Lines: 32

Joe Buck's proposal for using @ for exponentiation goes quite far, but
omits one important detail: what is the value of x@y?

That sounds like a trivial question -- it's just exponentiation, right? --
but it is actually far from trivial.  For example, if x@y is implemented
as exp(y*log(x)), the result will surely be inaccurate.  So what, if
anything, should the user be entitled to assume?  For example:

	Is x@2 guaranteed to be equal to x@2.0?  To x*x?

	Is x@3 guaranteed equal to x*x*x?  What if x*x*x is not
	the best possible approximation to the infinite-precision
	cube of x?  This problem becomes worse for higher powers.

	If x>1 and y>z, is it always true that x@y >= x@z?

	If the mathematically exact value of x@y can be exactly
	represented as a floating-point number, is that the result
	you must get?

The corresponding questions are much easier to answer for simpler
operations, especially in light of things like the IEEE floating-point
standard.  But that standard does not define an exponentiation operation,
perhaps because it is so difficult.

Of course, people have looked at all these issues for other languages.
The point is that a complete proposal for C++ must at least survey
what other languages have done and give a cogent argument for a
particular approach.
-- 
				--Andrew Koenig
				  ark@europa.att.com


