Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103695 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 73305 invoked from network); 7 Jan 2019 20:50:44 -0000 Received: from unknown (HELO dd16914.kasserver.com) (85.13.137.198) by pb1.pair.com with SMTP; 7 Jan 2019 20:50:44 -0000 Received: from dd16914.kasserver.com (dd0801.kasserver.com [85.13.143.205]) by dd16914.kasserver.com (Postfix) with ESMTPSA id 47D006480230 for ; Mon, 7 Jan 2019 18:24:39 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SenderIP: 178.19.211.76 User-Agent: ALL-INKL Webmail 2.11 To: internals@lists.php.net Message-ID: <20190107172439.47D006480230@dd16914.kasserver.com> Date: Mon, 7 Jan 2019 18:24:39 +0100 (CET) Subject: Re: [PHP-DEV] Proposal: change precision for output functions From: mails@thomasbley.de ("Thomas Bley") Semen Dubina wrote on 07.01.2019 16:38: > Hi, everyone! > Original PR and description see: https://github.com/php/php-src/pull/3460. > > Because of the accuracy constraint set by the 'precision' variable, debugging > problems often occur, and many developers consider the limited accuracy to be a > feature of the language. > For better compatibility with other languages and predictable behavior, I > suggest changing the default value of the variable 'precision' to -1. > In the tracker you can find several bugs in which people trusted output of > 'var_dump' and 'echo': > https://bugs.php.net/bug.php?id=66866 > https://bugs.php.net/bug.php?id=66959 > https://bugs.php.net/bug.php?id=68551 > https://bugs.php.net/bug.php?id=73358 > > Examples: https://3v4l.org/Mr4KM > > If you know a case when it will violate some task, describe it, please. I think > that the trusting of FLOAT is a very bad practice. > > -- Semen V. Dubina https://sam002.net/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Hello, good point, having: echo ini_get('precision') . PHP_EOL; echo ini_get('serialize_precision') . PHP_EOL; echo json_encode(array('price' => round('45.99', 2))) . PHP_EOL; echo (0.1+0.7), json_encode(0.1+0.7) . PHP_EOL; gives (https://3v4l.org/ldgo8): Output for 7.1.0 - 7.3.0 14 -1 {"price":45.99} 0.80.7999999999999999 Output for 5.3.6 - 5.6.38, 7.0.0 - 7.0.33 14 17 {"price":45.99} 0.80.8 what is the preferred way to upgrade from php 5.6 to 7.x in order to get the same results? Regards Thomas