CKTIS / PHP
PHP_INT_MAX / PHP_INT_MIN
Par PHP_INT_MAX / PHP_INT_MIN označava najveći i najmanji cijeli broj s predznakom prema širini tipa int u toj izvedbi.
Verzija: PHP 8.4; repository runtime, production runtime not attested
Sintaksa
$overflow = PHP_INT_MAX + 1;Par PHP_INT_MAX / PHP_INT_MIN označava najveći i najmanji cijeli broj s predznakom prema širini tipa int u toj izvedbi. Donja je granica -PHP_INT_MAX - 1. Obično zbrajanje ili oduzimanje izvan granica daje float, koji ne prikazuje točno sve velike cijele brojeve.
$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"]
Primjeri
<?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)
]);
Rezultat
[true,"int","int","float","float"]