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

From: Date: Wed, 01 Apr 2020 16:57:26 +0000
Subject: Bug #79443 [Nab]: round with precision is not rounding
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226399@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 Updated by: cmb@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: Also note that round() returns a float. Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2020-04-01 16:06:34] info at globules dot io Yes I have posted the exact code. ------------------------------------------------------------------------ [2020-04-01 15:48:07] danack@php.net Mr Info Are you sure that code you posted is actually the code that's producing that output? https://3v4l.org/v9k54 ------------------------------------------------------------------------ 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 (#226399) next »