CKTIS / PHP
PHP_INT_MAX / PHP_INT_MIN
O par PHP_INT_MAX / PHP_INT_MIN designa o maior e o menor inteiro com sinal consoante a largura dos inteiros da compilação.
Versão: PHP 8.4; repository runtime, production runtime not attested
Sintaxe
$overflow = PHP_INT_MAX + 1;O par PHP_INT_MAX / PHP_INT_MIN designa o maior e o menor inteiro com sinal consoante a largura dos inteiros da compilação. O limite inferior é -PHP_INT_MAX - 1. Uma soma ou subtração fora dos limites produz float, que não representa exatamente todos os inteiros grandes.
$above = PHP_INT_MAX + 1;
$below = PHP_INT_MIN - 1;
echo json_encode([
PHP_INT_MIN === -PHP_INT_MAX - 1,
get_debug_type(PHP_INT_MAX), get_debug_type(PHP_INT_MIN),
get_debug_type($above), get_debug_type($below)
]);
[true,"int","int","float","float"]
Exemplos
<?php
$above = PHP_INT_MAX + 1;
$below = PHP_INT_MIN - 1;
echo json_encode([
PHP_INT_MIN === -PHP_INT_MAX - 1,
get_debug_type(PHP_INT_MAX), get_debug_type(PHP_INT_MIN),
get_debug_type($above), get_debug_type($below)
]);
Resultado
[true,"int","int","float","float"]