Bug #75920 [NEW]: precision problem with decimals read from sql server
| From: | km dot wrona at gmail dot com | Date: | Mon, 05 Feb 2018 13:29:43 +0000 |
| Subject: | Bug #75920 [NEW]: precision problem with decimals read from sql server | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213818@lists.php.net to get a copy of this message | ||
From: km dot wrona at gmail dot com
Operating system: Alpine
PHP version: 7.1.14
Package: PDO DBlib
Bug Type: Bug
Bug description:precision problem with decimals read from sql server
Description:
------------
The number is not represented properly when the column is defined as
decimal.
Test script:
---------------
var_dump($this->selectRaw('CAST(\'1.6\' as decimal(10,2)) as dec,
CAST(\'1.6\' as float) as flo')->limit(1)->get());
exit;
array(1) {
[0]=> object(stdClass)#789 (2) {
["dec"]=> float(1.5999999999999)
["flo"]=> float(1.6)
}
}
//default behaviour
["dec"]=> float(1.5999999999999)
//with
//ini_set('precision', 25);
//ini_set('serialize_precision', 25);
["dec"]=> float(1.599999999999909050529823)
Expected result:
----------------
1.6 no matter if decimal or float
--
Edit bug report at https://bugs.php.net/bug.php?id=75920&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75920&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75920&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75920&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75920&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75920&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75920&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75920&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75920&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75920&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75920&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75920&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75920&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75920&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75920&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75920&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75920&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75920&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75920&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75920&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75920&r=mysqlcfg