0

I am talking about the file

vendor/magento/module-sales/Model/Order/Creditmemo/Total/Shipping.php

here in codes

if ($desiredAmount < $this->priceCurrency->round($maxAllowedAmount) + 0.0001) { 

And

if ($desiredAmount > $maxAllowedAmount - 0.0001) {

why is there addition and subtraction of the amount 0.0001

Can't this be done without this?

5
  • 1
    I think the comments in the code explain it : Note: ($x < $y + 0.0001) means ($x <= $y) for floats
    – paj
    Mar 5, 2021 at 14:58
  • Yes I have seen the comments, why not use directly $x <= $y. I never experienced issues in any float values this way either.
    – MSQ
    Mar 5, 2021 at 15:01
  • you can override this file in your custom module to meet your desired criteria
    – Pramod
    Mar 8, 2021 at 6:55
  • @Pramod yes I understand that. And I feel my question is not clear... I am just asking why have Magento creators opted for this way of solving the problem, Must be some big reason... Want to know that reason.
    – MSQ
    Mar 10, 2021 at 6:33
  • Any magento official here?
    – MSQ
    Mar 15, 2021 at 6:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.