Infinite Operations

<?php

var_dump( 2 * PHP_INT_MAX === 3 * PHP_INT_MAX);          // false
var_dump( PHP_FLOAT_MAX + 1 === 3 * PHP_FLOAT_MAX);      // false
var_dump( PHP_FLOAT_MAX + 1E+308 === 3 * PHP_FLOAT_MAX); // false
var_dump( 2 * PHP_FLOAT_MAX === 3 * PHP_FLOAT_MAX);      // true
var_dump( 2 * INF === 3 * INF);                          // true
var_dump( INF ** INF === INF);                           // true

?>

Here are some border line calculations with large numbers in PHP: calculating beyond PHP_INT_MAX is possible, as long as the resulting number is still… a number: here, it is a float. The same calculation is not possible with floats, because they are capped by infinite. Infinite is around 1E308.

In particular, adding extra elements to PHP_FLOAT_MAX yields strange comparisons: if the addition is small enough, it is rounded to 0, and ignored. This is not the case with multiplication, where the numbers are all going beyond PHP_FLOAT_MAX, and are turned into INF, which, by the way, is an float type.

Finally, using power ** on INF is still capped by INF, so it is valid calculation, without overflow.

See Also

PHP Features

Last updated: 13 August 2026