[PHP-DEV] Bug #1076 Updated: invalid cast from string to double From: Bug Database (php-dev <email protected>)
Date: 01/18/99

ID: 1076
User Update by: davids <email protected>
Old-Status: Open
Status: Closed
Bug Type: Misbehaving function
Description: invalid cast from string to double

I have this sample code:
<HTML>
<HEAD><TITLE>Test</TITLE>
</HEAD>
<BODY>
<?php
  for($i = 0; $i < 100000; $i++ )
  {
    $q = "122.123";
    $dq = (double)$q;
    $iq = (int)$q;

    if( $dq == $iq ) echo "$dq:$iq<BR>";
  }
?>
</BODY>

This looks like this code doesn't has visible output in browser. But, in rare cases, I see:
122:122
122:122
122:122
..... random times repeated
This looks like cast from "122.123" to double sometimes produces only 122, not 122.123. This is _rare_ and probably depends on system load etc.
PHP was compiled using egcs-1.1b, dynamic php module works with apache.
Config line:
./configure --prefix=/usr3/www/apache --with-shared-apache=/usr/src/david/apache_1.3.4 --with-gd --with-pgsql=/opt/pgsql --with-zlib --with-dbase --enable-debugger --enable-sysvshm --enable-sysvsem

Apache is 1.3.4.

===============================================
This bug is probably glibc-related and affect sometimes locale conventions. I'am not sure, but affected function 'strtod()' sometimes fails to recognize locale decimal point correctly. My locale(cs_CZ.ISO-8859-2) defines ','(comma) as decimal point and glibc sometimes fails.

Full Bug description available at: http://ca.php.net/bugs.php3?id=1076

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>