[SOLVED]Warning: sqrt() expects parameter 1 to be float
January 2, 2019 at 10:01 pm #5296
I´ve been struggling quite a while with this error message. We´re presenting our material to a customer tomorrow and I just can´t find a way around this problem. On this product ([b]https://techtinyhouse.de/shop/rohbau/staenderwerk/[/b]) I get the following error-message as you can see yourself on the site. If the calculations were still correct I wouldn´t bother with the warning for now. But the calculation isn´t correct.
[b]Warning: sqrt() expects parameter 1 to be float, string given in /home/techtiny/public_html/wp-content/plugins/woo-price-calculator/admin/resources/lib/PHPExcel/Classes/PHPExcel/Calculation.php on line 3452[/b]
I´m quite sure the warning didn´t exist before I put the conditional logic in. I deleted all of it again, but the warning doesn´t disappear anymore.I could upload fresh, but the conditional logic is mandatory.
– 3 screenshots of the calculation
– export ZIP-folder from WPC itself
– the php-file the warning is directing toJanuary 3, 2019 at 8:08 pm #5304
we were working on finding the solution of the problem that you present.
The error generated form your site its not created by our plugin or conditional logic but from the PHPExcel library.
The error is caused by the formulas sqrt() that you are using inside of your excel file.
Some of them are getting a string(text) argument instead of a float(number) value.
Please check the arguments that your sqrt() formulas takes.
Waiting for your feedback
AT979January 16, 2019 at 6:25 am #5303
I changed all “sqrt()” into “^0,5”. That solved the problem for which I initially opened this ticket. Though another occured and a second one I thought would be solved by the sqrt() is not. I documented this with the Screenshot and Excel “After” and “Before”.
As you see in the Screenshot “Wrong Numbers” the numbers in WPC are not the same as on the Front-End of the Website itself. How can I solve this problem since everything seems to be uploading correctly and then suddenly displays is differently on the front end.
The same goes for the screenshot “#DIV0!”. It uploads correctly, but then doesn´t display online at all. Can you help me out here?
BrendanJanuary 16, 2019 at 10:16 pm #5302
sorry for the delay of giving you an answer.
We are trying to find a solution of the problem that you present but we cant reproduce in our local environment.
Could you please send us the calculator.zip(export of the zip folder from WPC) with the new file that you have created so we can make a check ?
Waiting for your response.
AT979January 17, 2019 at 5:33 am #5301
let me know If I can supply more information.
BrendanJanuary 18, 2019 at 10:00 pm #5300
we were working on finding a solution for the problem that you present.
We notice that in the excel file that you are using in your calculator, your results have endless periodic number like in the filed of “Montage”.
You need to use “Round()” excel formula to round those endless periodic number, like this you don’t have problem with calculator.
Waiting for your feedback
AT979January 19, 2019 at 2:51 pm #5299
thanks for that tip. The numbers weren´t endless, but they were long. Something like 12 digits long. I´m stating that in case that makes a difference.
I´m not getting the “#DIV0!” anymore since I rounded as you suggested. So thats great. It is very clear now though that numbers with many digits are not taken in very well by WPC since the number that is being display instead of the #DIV0! isn´t correct either. Somehow the programm gets messed up.
So first I had a 1,40026841817559. That became a “#DIV0!” as described in my earlier messages to you. Then I rounded. So it became round(1,40026841817559) which obviously makes it 1,40. On the front end this becomes 11,90. So the problem has improved slightly since 11,90 is better than #DIV0!. But the number being displayed is of course not quite right yet.
That´s where I see the issue. Do you see any way around this?
1: This is where “1,40026841817559” I´m talking about is placed.
2: This is whats being displayed on the front end with round(1,40026841817559).January 23, 2019 at 9:12 pm #5298
you have to round the cells that contain simple mathematical calculation but returns long numbers. Like for example in the excel file you are using
the cell G3 has a formula that depends on a lot of other cells for example one is CD132, that by its own depends on other cells and this goes even more deeper. You have to make sure to round the cells of which this ones depends with the Round() formula that excel has
before summing them up. So the idea is to round every cell that will produce a long number before it is involved in other calculations. This will fix the problem.
AT979January 29, 2019 at 1:38 am #5297
I just wanted to let you know that the problem is solved. In the end it wasn´t the rounding of numbers that brought the difficulty. The problem laid in WPC pulling data differently then Excel. This isn´t a huge issue. It just means, that you have to troubleshoot extensively. Our tables are quite complex. So I might have to go back 10 steps and upload the data step for step to see where exactly the data is pulled in differently. It took me about 20 hours to solve all the problems, but what´s necessary is necessary. I just wanted to let you know that rounding the numbers is no issue at all. As far as I can see at this point WPC has no problem at all with cells that have, lets say, 15 decimals.
- You must be logged in to reply to this topic.