Difference in calculation between Excel and PHP

Asked

Viewed 40 times

-2

I am transforming an excel spreadsheet into a PHP system, but when validating some values I noticed that PHP is different from excel. I have to do the following:

  • PHP (166 / 161,1) = 1,03416
  • Excel (166 / 161,1) = 1,030558

I still have to multiply by 100 the result and again the different.

  • PHP = 103,0
  • Excel = 103,1

Excel is always rounding this generating difference in the information I need to treat.

In php I’ve tried the following functions:

  • bcdiv
  • floor
  • sprintf("%01.4f", (166.0/161.1));
  • abs

In Windows calculator retonna the same value of PHP only in excel is against. Someone has already gone through this has some hint to get to the same value or as close as possible to excel?

Thanks in advance for your attention and cooperation.

  • On my Calculator 166 161.1 = 1.0304158907510863. Your Excel is interpreting the , correctly?

  • achoq that you transcribed the wrong PHP result there -PHP would not give out so much - the result is 1.030415 Better you put exactly the expressions you are using, in each language and environment, otherwise no one will be able to help you: of the exact value of excel formica, and the PHP code you are using.

1 answer

0

I believe your Exel is set to round up. There is a function to fix this follows a video https://youtu.be/eoORSGiA9es. Another option is to round in php, ai depends on which one makes the most sense to you. I hope I helped minimanete.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.