Edit report at https://bugs.php.net/bug.php?id=55368&edit=1
ID: 55368 User updated by: ygautheron at absystech dot fr Reported by: ygautheron at absystech dot fr Summary: ini_set('precision',16) is affecting a simple math result Status: Open Type: Bug Package: *Math Functions Operating System: Linux Gentoo (2.6.38-gentoo-r6) PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Just noticed that i we try 0.196*100 it works good too. The problem seems to come from the substract ? Previous Comments: ------------------------------------------------------------------------ [2011-08-05 08:21:32] ygautheron at absystech dot fr Description: ------------ Hello, The simple calculation does not result the same if we set the precision to 16. Maybe it's cpu architecture related ? Precision lower than 16 : (1.196 - 1) * 100 => 19.6 Precision 16 : (1.196 - 1) * 100 => 19.59999999999999 Precision 17 : (1.196 - 1) * 100 => 19.599999999999994 ... Here's the configure parameters : './configure' '--prefix=/usr' '--build=x86_64-pc-linux-gnu' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--prefix=/usr/lib64/php5.3' '--mandir=/usr/lib64/php5.3/man' '--infodir=/usr/lib64/php5.3/info' '--libdir=/usr/lib64/php5.3/lib' '--with-libdir=lib64' '--without-pear' '--disable-maintainer-zts' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-curl' '--with-curlwrappers' '--without-enchant' '--enable-exif' '--enable-ftp' '--with-gettext' '--without-gmp' '--without-mhash' '--disable-intl' '--without-kerberos' '--enable-mbstring' '--with-mcrypt' '--without-mssql' '--with-onig=/usr' '--with-openssl' '--with-openssl-dir=/usr' '--disable-pcntl' '--without-pgsql' '--without-pspell' '--without-recode' '--disable-shmop' '--with-snmp' '--disable-soap' '--enable-sockets' '--without-sqlite3' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--with-tidy' '--disable-wddx' '--with-xmlrpc' '--with-xsl' '--enable-zip' '--with-zlib' '--disable-debug' '--enable-dba' '--without-cdb' '--with-db4' '--disable-flatfile' '--with-gdbm' '--disable-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--with-imap' '--with-imap-ssl' '--with-ldap' '--without-ldap-sasl' '--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-unixODBC=/usr' '--without-adabas' '--without-birdstep' '--without-dbmaker' '--without-empress' '--without-esoob' '--without-ibm-db2' '--without-sapdb' '--without-solid' '--with-iodbc=/usr' '--without-oci8' '--with-oci8=instantclient,/usr/lib/oracle/10.2.0.3/client/lib' '--without-pdo-dblib' '--with-pdo-mysql=/usr' '--without-pdo-pgsql' '--without-pdo-sqlite' '--with-pdo-odbc=unixODBC,/usr' '--with-pdo-oci=instantclient,/usr,10.2.0.3' '--with-readline' '--without-libedit' '--without-mm' '--without-sqlite' '--with-pic' '--with-pcre-regex=/usr' '--with-pcre-dir=/usr' '--with-config-file-path=/etc/php/apache2-php5.3' '--with-config-file-scan-dir=/etc/php/apache2-php5.3/ext-active' '--disable-embed' '--disable-cli' '--disable-cgi' '--disable-fpm' '--with-apxs2=/usr/sbin/apxs' Test script: --------------- Interactive shell php > var_dump(phpversion()); string(16) "5.3.6-pl0-gentoo" php > var_dump((1.196-1)*100); float(19.6) php > var_dump(ini_get('precision')); string(2) "14" php > var_dump(ini_set('precision',14)); string(2) "14" php > var_dump((1.196-1)*100); float(19.6) php > var_dump(ini_set('precision',15)); string(2) "14" php > var_dump((1.196-1)*100); float(19.6) php > var_dump(ini_set('precision',16)); string(2) "15" php > var_dump((1.196-1)*100); float(19.59999999999999) php > var_dump(ini_set('precision',17)); string(2) "16" php > var_dump((1.196-1)*100); float(19.599999999999994) php > var_dump(ini_set('precision',18)); string(2) "17" php > var_dump((1.196-1)*100); float(19.5999999999999943) Expected result: ---------------- I think the result must always be the same : (float)19.6 Actual result: -------------- php > var_dump(ini_set('precision',16)); string(2) "15" php > var_dump(("1.196"-1)*100); float(19.59999999999999) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55368&edit=1