Bug #78562 [Opn]: money_format() returns string with incorrect number

From: Date: Wed, 18 Sep 2019 21:24:09 +0000
Subject: Bug #78562 [Opn]: money_format() returns string with incorrect number
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222814@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78562&edit=1 ID: 78562 User updated by: candace dot camarillo at vacasa dot com Reported by: candace dot camarillo at vacasa dot com Summary: money_format() returns string with incorrect number Status: Open Type: Bug Package: *Math Functions Operating System: Apline Linux 3.8 PHP Version: 7.2.22 Block user comment: N Private report: N New Comment: However, hard-coding this number into the money_format() method causes the error, too. Previous Comments: ------------------------------------------------------------------------ [2019-09-18 21:22:44] candace dot camarillo at vacasa dot com Our production code used some math to come up with this number. It just so happened that when we upgrading our project to PHP7, a test failed that expected the correct number. So I only found this particular number by chance. ------------------------------------------------------------------------ [2019-09-18 20:56:37] requinix@php.net Are you hardcoding 2040.33 into your script? Or did you do some math to get that number? ------------------------------------------------------------------------ [2019-09-18 19:42:09] candace dot camarillo at vacasa dot com Description: ------------ --- From manual page: https://php.net/function.money-format --- Running money_format() with the number 2040.33 returns a string with 2040.32. Other numbers seem to work. I have not iterated through others to determine which cause the problem. Playing with locale and other flags makes no impact on the problem. Test script: --------------- echo money_format('%i', 2040.33); // returns '2040.32' Expected result: ---------------- '2040.33' Actual result: -------------- '2040.32' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78562&edit=1

« previous php.bugs (#222814) next »