View Issue Details

IDProjectCategoryView StatusLast Update
0002264XdebugUncategorizedpublic2024-05-10 16:32
Reporterconnor Assigned Toderick  
PrioritylowSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version3.2.0 
Target Version3.3dev 
Summary0002264: Rounding of fractional numbers
Description

The following source code rounds infinite decimal fractions on several php 8 and xdebug versions. It doesn't seem to truncate the decimal part (like converting to int would do), but does a proper rounding. The problem is that in the IDE, when I look at the value of the variable, it also shows the rounded value (see attached image).

With Xdebug:
239749.99999999997
/Users/connor/Work/forms/test.php:9:
double(239750)
double

Without Xdebug:
239749.99999999997
float(239749.99999999997)
double

Steps To Reproduce

<?php

$s = 342_500;
$s *= 0.7;
echo var_export($s);
echo PHP_EOL;
var_dump($s);
echo gettype($s);
echo PHP_EOL;

TagsNo tags attached.
Attached Files
Operating Systemmacos
PHP Version8.2.0-8.2.9

Activities

derick

2024-05-06 10:39

administrator   ~0006943

I think I looked into this in the past, and from what I remember, Xdebug uses a standard PHP API for this... that is also inconsistent. I'll have another look.

derick

2024-05-10 16:32

administrator   ~0006955

It turned out that this was indeed a change in PHP 8.0.0:
https://github.com/php/php-src/commit/a9398056417d27cb1754cdb846411c695d3afe10

PR:
https://github.com/xdebug/xdebug/pull/961

Issue History

Date Modified Username Field Change
2024-04-23 16:52 connor New Issue
2024-04-23 16:52 connor File Added: Screenshot 2024-04-23 at 18.50.14.png
2024-05-06 10:39 derick Assigned To => derick
2024-05-06 10:39 derick Status new => acknowledged
2024-05-06 10:39 derick Note Added: 0006943
2024-05-10 16:32 derick Note Added: 0006955
2024-05-10 16:32 derick Target Version => 3.3dev