CKTIS / PHP
INF
INF es el infinito positivo de coma flotante y -INF el negativo.
Versión: PHP 8.4; repository runtime, production runtime not attested
Sintaxis
is_infinite(INF)INF es el infinito positivo de coma flotante y -INF el negativo. Están por encima y por debajo, respectivamente, de todos los números finitos. La diferencia INF - INF produce NaN, detectable con is_nan. JSON no representa infinito, así que JSON_THROW_ON_ERROR provoca JsonException.
echo json_encode([is_float(INF), is_infinite(-INF), INF > PHP_FLOAT_MAX, is_nan(INF - INF)]), PHP_EOL;
try { json_encode(INF, JSON_THROW_ON_ERROR); } catch (JsonException $e) { echo get_class($e); }
[true,true,true,true]
JsonException
Ejemplos
<?php
echo json_encode([is_float(INF), is_infinite(-INF), INF > PHP_FLOAT_MAX, is_nan(INF - INF)]), PHP_EOL;
try { json_encode(INF, JSON_THROW_ON_ERROR); } catch (JsonException $e) { echo get_class($e); }
Resultado
[true,true,true,true] JsonException