Mantis - Quercus
Viewing Issue Advanced Details
3279 block always 01-17-09 12:43 01-18-09 09:32
koreth  
ferg  
normal  
closed 4.0.0  
fixed  
none    
none 4.0.0  
0003279: Default floating-point formatting uses exponent notation too early
<?php
$x = 1.0;
while ($x < 100000000000000000000.0) {
  print $x . "\n";
  $x *= 10.1;
}

PHP prints:

1
10.1
102.01
1030.301
10406.0401
105101.00501
1061520.150601
10721353.52107
108285670.56281
1093685272.6844
11046221254.112
111566834666.53
1126825030132
11380932804333
114947421323760
1160968955370000
11725786449237000
118430443137290000
1.1961474756867E+18
1.2081089504435E+19

Quercus prints:

1
10.1
102.00999999999999
1030.301
10406.040099999998
105101.00500999998
1061520.1506009998
1.0721353521070099E7
1.0828567056280799E8
1.0936852726843607E9
1.1046221254112043E10
1.1156683466653163E11
1.1268250301319695E12
1.138093280433289E13
1.1494742132376219E14
1160968955369998
11725786449236980
118430443137293488
1196147475686664192
1.2081089504435309E19

The floating point errors are not a big deal (though rounding them to be output-compatible with PHP wouldn't hurt) but the fact that Quercus starts using exponent notation far earlier than PHP does is causing problems with some code that's expecting to be able to do simple parsing of floats within a particular range.

Notes
(0003757)
ferg   
01-18-09 09:32   
php/1003