Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108655 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59410 invoked from network); 18 Feb 2020 13:04:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Feb 2020 13:04:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2A1791804F6 for ; Tue, 18 Feb 2020 03:20:36 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 18 Feb 2020 03:20:35 -0800 (PST) Received: by mail-lf1-f50.google.com with SMTP id v201so14187125lfa.11 for ; Tue, 18 Feb 2020 03:20:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=SHcCAkyzB68+b+NdjkZk+RroC8jhubFCEKuikiIc6fI=; b=ZV5PaGvaN12/HhXYlvTDqfbyXbqVFJXF9QPW+jcycScM4+Hn1ceImG0FVYrq6dK5f7 /v++uIdATIfPBNOJduU84f3moIf9Cnx8VMgXDexbHQDF/BuqK68dSxfMWgfK+QzmLE67 dSoDBgmag39cnMcFsXWsD33SP6PewSO/BSXxsyKkbhMIto217af7bM8VC+9iXEx4TM1o 1EdBR2VYab7MHRFV00J/PtJ7xJV0fmColpwjLxxUesFaZYGaIRoX+z5S93I8oZKpYAgp 43myW179ryFchD6MeNsOQmhXflT5ipd5mD6y6yygCrRqWLcH0M45nNWa61uF0ylJHM0N etgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=SHcCAkyzB68+b+NdjkZk+RroC8jhubFCEKuikiIc6fI=; b=IOyqNH9HIlJ0lLzLuzetVz7YMLEGV9gk41yrEOGKIEBcG+eT+HjHQ8SiaZfIn02XIn NEiD0wkUZ6116RkEQnT5WihDB6uayrvXp/IxuKtD8w68cKesqOo3XvRQ8gOlqzpzsMSy MCwBvAolJEqw6KhYEVfe39AnRUKsc+c3abXMqcO0/r+N9yjSEiaNFIYleiXFE8+mg2gk ooaatVEifppEUxoSbZkkMOMBsebjKJa1WxqmIe7OqFsPCgJR3MTpnMS6NTrBtB9j6OE+ HR9qrHn0RipSdztiVCmYRMvV42/CWB8XruGpxrsfNJGpGt6C1N2fUivZyRGJuQkG1ZUz oWJg== X-Gm-Message-State: APjAAAWy3LEpKQDPhDiyT5R/5GGj1swQJc06CSfvR4wqFDGDKcmZN6Lt eqS1I80ujIEKVKIKWwk0w3gDkFPblprlS327fE5/ZkZvQO8+ww== X-Google-Smtp-Source: APXvYqz9PDN9NtE1FovypK//6Kb4NIGMcD99hW1pEbDQBWfNIugobiD2I9YVxkq92+YruXawJ9GqZnGtJIrVKgdcGSY= X-Received: by 2002:a19:9d5:: with SMTP id 204mr10123335lfj.120.1582024833812; Tue, 18 Feb 2020 03:20:33 -0800 (PST) MIME-Version: 1.0 Date: Tue, 18 Feb 2020 12:20:18 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000003ecad0059ed7dcf8" Subject: Make var_dump() use serialize_precision From: nikita.ppv@gmail.com (Nikita Popov) --0000000000003ecad0059ed7dcf8 Content-Type: text/plain; charset="UTF-8" Hi internals, https://github.com/php/php-src/pull/5172 changes var_dump() to use serialize_precision instead of precision to dump floating-point numbers. To recap: serialize_precision defaults to -1, which will print exactly as many floating-point digits as are needed to represent the number accurately. precision defaults to 14, which will print a shorter but potentially inaccurate float representation. The motivation here is that var_dump() is debugging functionality and should print values as accurately as possible. The single most common bug report we receive is some kind of variation on: $sum = 0.1 + 0.2; var_dump($sum); // float(0.3) var_dump($sum == 0.3); // bool(false) WTF??? After this change, this would instead be: $sum = 0.1 + 0.2; var_dump($sum); // float(0.30000000000000004) var_dump($sum == 0.3); // bool(false) Makes sense... I have little hope that developers will suddenly start understanding floating-point numbers, but at least this should reduce the amount of confusion. Does anyone see an issue with doing this change? Regards, Nikita --0000000000003ecad0059ed7dcf8--