Yii2: Yii2 trace logs floating numbers wrongly

Created on 23 Feb 2018  ·  3Comments  ·  Source: yiisoft/yii2

What steps will reproduce the problem?

\Yii::trace(23.10, 'debug');

What is the expected result?

23.10

What do you get instead?

23.10000000000000142108547152020037174224853515625

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.?
| PHP version | 5.6
| Operating system | mac os 10.12.6

to be verified bug

Most helpful comment

The problem is here with the function var_export(23.10, true). Which subsequently drills down to how actually floating point numbers are dealt in a language.
PHP manual warns on _floating point numbers_:

Floating point numbers have limited precision. Although it depends on the system, PHP typically uses the IEEE 754 double precision format, which will give a maximum relative error due to rounding in the order of 1.11e-16.

All 3 comments

What version of Yii is that?

Yii version : 2.0.13

On Fri, Feb 23, 2018 at 11:32 PM, Alexander Makarov <
[email protected]> wrote:

What version of Yii is that?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/yiisoft/yii2/issues/15752#issuecomment-368089726, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ATixVKCDsP-FrcDFJXEHYHxX8O89TbRwks5tXv0ygaJpZM4SRBVi
.

The problem is here with the function var_export(23.10, true). Which subsequently drills down to how actually floating point numbers are dealt in a language.
PHP manual warns on _floating point numbers_:

Floating point numbers have limited precision. Although it depends on the system, PHP typically uses the IEEE 754 double precision format, which will give a maximum relative error due to rounding in the order of 1.11e-16.

Was this page helpful?
0 / 5 - 0 ratings