CKTIS / PHP
Exponentiation (**)
Raise a base to an exponent to calculate geometric growth.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$value ** $operandRaise a base to an exponent to calculate geometric growth. Chained powers group from the right.
The left operand is the base and the right operand is the exponent. A negative exponent can yield a fraction even for an integer base. Parentheses determine whether a minus sign belongs to the base.
Evaluation
2 ** 5→322 ** (-2)→0.259 ** 0→1
Examples
<?php
echo json_encode(2 ** 5), PHP_EOL;
echo json_encode(2 ** (-2)), PHP_EOL;
echo json_encode(9 ** 0), PHP_EOL;
Result
32 0.25 1