Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

247
Vistas
Why does PHP not recognize the sequence of digits from PHP_INT_MIN as an integer

With

var_dump(PHP_INT_MIN);
//int(-9223372036854775808)

I get the number -9223372036854775808. If I assign this number to a variable, it is of the float type.

$n = -9223372036854775808;
var_dump($n);
//float(-9.2233720368548E+18)

This gives me integers:

$n = PHP_INT_MIN;
var_dump($n);
//int(-9223372036854775808)

and

$n = intval("-9223372036854775808");
var_dump($n);
//int(-9223372036854775808)

and

$n = sscanf("-9223372036854775808","%d")[0];
var_dump($n);
//int(-9223372036854775808)

Why does PHP give me a float type for -9223372036854775808 ?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Because the minus sign is not part of the syntax of a number in source code, it's the unary negation operator. So

$n = -9223372036854775808;

is treated like

$n = -(9223372036854775808);

But 9223372036854775808 is larger than PHP_INT_MAX, so it's parsed as a float, and then negated.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda