Bug #75004 [NEW]: Certain floats * 100 type cast to int value one less then they should be
From: c dot m dot tatro at gmail dot com
Operating system: ubuntu
PHP version: 7.1.7
Package: *General Issues
Bug Type: Bug
Bug description:Certain floats * 100 type cast to int value one less then they should be
Description:
------------
PHP 7.1.7-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Jul 7 2017
10:07:42) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.7-1+ubuntu14.04.1+deb.sury.org+1, Copyright
(c) 1999-2017, by Zend Technologies
echo (int) (66.74*100); // 6673
echo (int) (35.55*100); // 3554
echo (int) (34.12*100); // 3411
To get a larger list run:
for ($i=0; $i<=1000; $i++) { echo (int) (((float)$i/100)*100) ."\r\n";}
Test script:
---------------
echo (int) (66.74*100);
echo (int) (35.55*100);
echo (int) (34.12*100);
for ($i=0; $i<=1000; $i++) { echo (int) (((float)$i/100)*100) ."\r\n";}
--
Edit bug report at https://bugs.php.net/bug.php?id=75004&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75004&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75004&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75004&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75004&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75004&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75004&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75004&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75004&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75004&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75004&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75004&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75004&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75004&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75004&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75004&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75004&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75004&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75004&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75004&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75004&r=mysqlcfg
Thread (2 messages)
- c dot m dot tatro at gmail dot com