Database
Enthusiast

## Bug in exponentiate ** operator precedence and associativity ?

Consider below query:

`SELECT 2**3**4`

as a result teradata returns value of expression 4096. This means that provided expression was calculated in this way:

`//Teradata left associative (probably wrong):((2**3)**4) = 4,096`

But this is wrong !

When expression contains operators with same precedence then normally expression is evaluated from left - to right. But exponentiate operator is evaluated from right to left.

This means that presented expression should be evaluated in this way:

`//Google and Mathematical theory says that 2**3**4 is right associative(2**(3**4)) = 2,417,851,639,229,260,000,000,000`

Try to evaluated this expression in for ex. google. Expression is evaluated from right to left. Also wikipedia describes this problem in this articel: http://en.wikipedia.org/wiki/Operator_associativity in same way as google evaluates this kind of expressions saying that operator is right associative.

Why Teradata is evaluating this operator from left to right ? Is it just a bug or intended behaviour?