Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / PHP

PHP_INT_MAX / PHP_INT_MIN

El par PHP_INT_MAX / PHP_INT_MIN designa el mayor y menor entero con signo según la anchura de enteros de la compilación.

Versión: PHP 8.4; repository runtime, production runtime not attested

Sintaxis

$overflow = PHP_INT_MAX + 1;

El par PHP_INT_MAX / PHP_INT_MIN designa el mayor y menor entero con signo según la anchura de enteros de la compilación. El límite inferior vale -PHP_INT_MAX - 1. Sumar o restar más allá del límite produce float, que no representa exactamente todos los enteros 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"]

Ejemplos

<?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"]

Fuentes