Am Mittwoch 08 Juni 2011, 16:48:49 schrieb Regina Henschel:

> > 2^3^2 gibt falsch  64  soll *512*
> 
> Der Operator ^ ist als links-assoziativ definiert (ODF1.2 part2 chapter
> 5.5). Daher wird der Ausdruck von links her gruppiert, was (2^3)^2 ergibt.

Moin, ich dachte immer, Potenzieren ist rechts-assoziativ. :-)

http://de.wikipedia.org/wiki/Operatorassoziativit%C3%A4t

Da steht Potenzierung in der Mathematik: a^b^c = a^(b^c)


Kleiner Perl-Test (** gleich potenzieren):

$ perl -le 'print 2 ** 3 ** 2'
512

Kleiner Python-Test:

$ python
>>> 2 ** 3 ** 2
512

Glaubst du, dass die alle falsch rechnen?

Gruß Uwe
-- 
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help

Antwort per Email an