owebia / magento2-module-advanced-shipping

Other
90 stars 28 forks source link

decimal point problem #70

Closed snownarrow closed 4 years ago

snownarrow commented 4 years ago

Hello,I installed the Advanced Shipping by Owebia in the Magento2.3,then set the shipping Configuration and open the debug view, I see some calculations have too many decimal points,as 8.3 be 8.300000000000001. can you help me,thank you! the rule example addMethod('id_001', [ 'title' => "Delivery to " . $request->dest_country_id, 'price' => 396.990 + 8.3 * (substr($request->package_weight, 0, 2)), ]);

the debug view addMethod('id_001', ['title' => "Delivery to " . $request->dest_country_id, 'price' => 396.99 + 8.300000000000001 * substr($request->package_weight, 0, 2)])

owebia commented 4 years ago

Hi,

This is due to floating point precision in PHP language. This is explained here : https://www.php.net/manual/en/language.types.float.php

But it should not have an impact on the final value of your shipping fees as Magento truncate it on display and when stored in database.

Best Regards, A.L.