Bug #79443 [Com]: round with precision is not rounding

From: Date: Wed, 01 Apr 2020 17:32:56 +0000
Subject: Bug #79443 [Com]: round with precision is not rounding
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226401@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79443&edit=1 ID: 79443 Comment by: tiffany@php.net Reported by: info at globules dot io Summary: round with precision is not rounding Status: Not a bug Type: Bug Package: *General Issues Operating System: Windows 10 x64 PHP Version: 7.4.4 Assigned To: cmb Block user comment: N Private report: N New Comment: If it's any help at all, the most I've changed in my php.ini file is adding the file path for logging, otherwise everything has been left default. Maybe do a diff with a default php.ini file against your current php.ini file. Previous Comments: ------------------------------------------------------------------------ [2020-04-01 17:02:09] info at globules dot io Oh I see, our precision on the win box in the php.ini is different... I guess that's the difference we see. Not sure how to fix it now but thanks. ------------------------------------------------------------------------ [2020-04-01 16:57:26] cmb@php.net Also note that round() returns a float. ------------------------------------------------------------------------ [2020-04-01 16:51:22] bugreports at gmail dot com > I am on Windows 10 Pro x64 and ran this from command prompt yeah, but you didn't mangle the "precision" config (look at the subejct) garbage in, garbage out and so we are at: Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations php -n -d precision=100 -r "echo round(-80.0035326999999938, 6);" -80.00353300000000444924808107316493988037109375 ------------------------------------------------------------------------ [2020-04-01 16:40:27] tiffany@php.net I am on Windows 10 Pro x64 and ran this from command prompt. C:\Users\Tylae>php -r "echo round(-80.0035326999999938, 6);" -80.003533 ------------------------------------------------------------------------ [2020-04-01 16:10:18] info at globules dot io How is this not a bug? This is the exact code. I'm rounding with precision, it works on Linux, doesn't work on Windows. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=79443 -- Edit this bug report at https://bugs.php.net/bug.php?id=79443&edit=1

« previous php.bugs (#226401) next »