Bug #79301 [Nab]: Float number issue when using in class property

From: Date: Mon, 24 Feb 2020 14:53:01 +0000
Subject: Bug #79301 [Nab]: Float number issue when using in class property
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225706@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79301&edit=1 ID: 79301 Updated by: nikic@php.net Reported by: dirk dot gerigk at tui dot com Summary: Float number issue when using in class property Status: Not a bug Type: Bug Package: Variables related Operating System: Linux PHP Version: 7.4.3 Block user comment: N Private report: N New Comment: Your code behaves the same way whether the value is assigned to a property or not, see https://3v4l.org/CQEd7 for example. Previous Comments: ------------------------------------------------------------------------ [2020-02-24 14:49:44] dirk dot gerigk at atraveo dot com May point in the first place, was that it only happens when you bind the result directly into a class property. If you are using an variable it won't happen. Rounding is not a case for my related code. Thanks for the fast reply. ------------------------------------------------------------------------ [2020-02-24 14:45:52] nikic@php.net var_export() prints accurate result, string conversion prints results rounded to precision=14 by default. Use precision=-1 if you want string conversion to print non-rounded results. There is no relation to properties here at all. ------------------------------------------------------------------------ [2020-02-24 14:43:15] bugreports at gmail dot com > This was working in PHP 5.5 irrelevant - the value for "precision" may have changed and it worked only by luck > and some number work some no irrelevant > This can be right it can - roud the values before the output ------------------------------------------------------------------------ [2020-02-24 14:39:44] dirk dot gerigk at atraveo dot com at nikic@php.net This was working in PHP 5.5 And this is an calculation with just multiply with 1000 and some number work some not. Also if you not bind the value to an class variable that will not happen. This can be right. ------------------------------------------------------------------------ [2020-02-24 14:35:55] nikic@php.net 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. If you would like to know more about "floats" and what IEEE 754 is, read this: http://www.floating-point-gui.de/ Thank you for your interest in PHP. ------------------------------------------------------------------------ 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=79301 -- Edit this bug report at https://bugs.php.net/bug.php?id=79301&edit=1

« previous php.bugs (#225706) next »