Warning!
The use of gawkisms will prevent the script from running correctly on systems that use a traditional awk interpreter.
The doublestar exponent operator is not available in traditional implementations
- Traditional awk implementations do not provide an exponent arithmetic operator. The [[doublestar?]] symbol used here for arithmetic exponential operations is a gawkism and will not work in traditional awk.
The doublestar gawkism
- The [[doublestar?]] gawkism acts as a dyadic exponent operator. It returns the [[value?]] given as a left [[operand?]] to the power of the right [[operand?]]. The [[operand?]]s can be [[floating_poin?]]t values, producing a [[floating_point?]] value:
print (4 ** 3) # 64 (4 to the power of 3)
Precedence
print (2 * 4 ** 3) # 128 the exponent has a higher precedence than multiplication
Exponent Combination Assignment Operator
- The exponent [[combination_assignment_operator?]] gawkism represented by a [[starstarequals?]] trigraph, can also be used to perform an exponent calculation:
value **= 3 # value = value ** 3