For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > August 2007 > #42432 [Opn]: large numbers ending with zeroes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #42432 [Opn]: large numbers ending with zeroes
zoxx at konto dot pl

2007-08-27, 9:01 am

ID: 42432
User updated by: zoxx at konto dot pl
Reported By: zoxx at konto dot pl
Status: Open
Bug Type: Documentation problem
Operating System: FreeBSD
PHP Version: 5.2.3
New Comment:

The problem is not internal representation, but float -> string
conversion made while 'echo' or while inserting to a string (like
$txt="value: $val";).

It is not working same as in php4 (I have tested that scripts with php4
too - the result is correct there: no exponent notation used).


Previous Comments:
------------------------------------------------------------------------

[2007-08-27 09:32:19] jani@php.net

It's not working any differently than in PHP 4. Internally it's the
same value. Reclassified.

------------------------------------------------------------------------

[2007-08-27 09:23:22] zoxx at konto dot pl

It is not described in manual.


Additional tests (FreeBSD, Windows XP SP 1):

<?php
echo 4100000*1.0;
?>

expected result: 4100000
actual result: 4.1E+6

Notice:
1) it is not float precision problem
2) script is working correctly on php4

------------------------------------------------------------------------

[2007-08-27 08:45:10] jani@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php



------------------------------------------------------------------------

[2007-08-26 19:59:53] zoxx at konto dot pl

Description:
------------
Bug related with Bugs #41811, #41152.

It's not really round() problem but string conversion made by echo or
concatenation with string.

It is serious bug with strong consequences:
- php4 was free with that 'feature' so old correctly working scripts
could fail with php5
- data that is inserted to mysql with exponent notation to mysql
integer fields is cutted to digits (so if you insert 1.41E+7 '1' integer
is inserted instead)
- data could be not displayed correctly, not correctly inserted to
files or passed to external systems (and so on...)
- it is unrelated with 'precision' php.ini configuration item, so
unexpected by programmer

Reproduce code:
---------------
<form action="testval.php" method=POST>
<input type=text name=val>
</form>
<?php
echo $val*100.0;
?>

Expected result:
----------------
input: 410000
output: 41000000

Actual result:
--------------
input: 410000
output: 4.1E+7


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=42432&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com