[php-src] Issue #14345: Zero decimals should be ignored when casting to int
| From: | mvorisek | Date: | Tue, 28 May 2024 15:30:26 +0000 |
| Subject: | [php-src] Issue #14345: Zero decimals should be ignored when casting to int | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246976@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14345
Author: mvorisek
### Description
The following code:
```php
<?php
$v = (string) PHP_INT_MAX;
var_dump($v);
var_dump((int) ($v . '.0'));
$v = (string) (PHP_INT_MAX - 1);
var_dump($v);
var_dump((int) ($v . '.0'));
```
online repro: https://3v4l.org/rtTtl
Resulted in this output:
```
string(19) "9223372036854775807"
int(9223372036854775807)
string(19) "9223372036854775806"
int(9223372036854775807)
```
But I expected this output instead:
```
string(19) "9223372036854775807"
int(9223372036854775807)
string(19) "9223372036854775806"
int(9223372036854775806)
```
### PHP Version
any
### Operating System
any