View Issue Details

IDProjectCategoryView StatusLast Update
0002264XdebugUncategorizedpublic2024-05-29 09:39
Reporterconnor Assigned Toderick  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.2.0 
Target Version3.3devFixed in 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

derick

2024-05-29 09:22

administrator   ~0006963

Fixed in GIT.

connor

2024-05-29 09:39

reporter   ~0006964

Thank you very much for looking into the bug and thank you for fixing it! Kudos!

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
2024-05-29 09:22 derick Status acknowledged => closed
2024-05-29 09:22 derick Resolution open => fixed
2024-05-29 09:22 derick Fixed in Version => 3.3dev
2024-05-29 09:22 derick Note Added: 0006963
2024-05-29 09:39 connor Note Added: 0006964