Skip to content

Literal value of PHP_INT_MIN is converted to float #1186

@ragol

Description

@ragol

Description

The following code:

<?php

var_dump(-9223372036854775807);
var_dump(-9223372036854775808);
var_dump(PHP_INT_MIN);
var_dump(-9223372036854775807 - 1 === PHP_INT_MIN);
var_dump(-9223372036854775808 === PHP_INT_MIN);

Resulted in this output in PHP 8 (all versions):

int(-9223372036854775807)
float(-9.223372036854776E+18)
int(-9223372036854775808)
bool(true)
bool(false)

Resulted in this output in PHP 7 (all versions):

int(-9223372036854775807)
float(-9.2233720368548E+18)
int(-9223372036854775808)
bool(true)
bool(false)

But I expected this output instead:

int(-9223372036854775807)
int(-9223372036854775808)
int(-9223372036854775808)
bool(true)
bool(true)

PHP Version

all versions of PHP 7 and 8

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions