|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-12 03:39 UTC] charlesb at ekit-inc dot com
Description:
------------
Basically we're seeing long floats being given a string value of -Infinity, even if we explicitly cast the variable. Python can handle these vars no problem, don't see why PHP can't?
Thanks
Reproduce code:
---------------
<?php
$a = '6.48261999999999982691178956883959472179';
$c = (double) $a;
$b = sprintf("%0.2f", $c);
print $c.' '.$b;
?>
Expected result:
----------------
6.48261999999999982691178956883959472179 6.48
Actual result:
--------------
-Infinity -0N
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
Can't help you with access to a sol box, but I can confirm it is that function at fault. On FC 1 the following C code produces the correct result but on solaris it produces -Inf, ie is a bug. You might be interested to know that the solaris strtod function can handle the number no problems, so if you rolled your own zend_strtod function to get around an OS bug, you don't need to for Solaris :) char *cp; double a = zend_strtod("6.48261999999999982691178956883959472179", &cp); printf("%g\n", a);