Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Calculations Not Accurate on Large Numbers 05.06.2012 21:29

Hello,

I'm having an issue with this formula:

$cubic=$len1*$wit1*$hei1/166;
$sum=$cubic;
$actual=$act1;
if ($actual > $cubic)
$sum=$actual;
$sum=number_format($sum,2);
$cubic=number_format($cubic,2);
$total=$rates1*$sum;
$total=number_format($total,2);

On the site I have a cost calculator that takes the Length X Width X Height - The Actual Weight - and then multiples it by the chosen Rate.

I seems to work accurately with small numbers but when I enter 100x100x100 then 250 (for actual weight) and choose 1.57 per pound on the cost the results are not accurate.

The way this calculation is supposed to work (it does with smaller numbers) is it first calculates the cubic weight LxWxH which in this case would be 1,000,000 then compares it to the Actual Weight which is 250, then chooses the larger between the Cubic weight and Actual Weight and then multiples by the Rate..which is $1.57.

When I click calculate it spits out $9.49 when it should be $9457.84 - now if I take the LxWxH and use say 20x20x20 and 250 for the actual weight and $157 for the rate it calculates correctly at $392.50

I'm not sure why it is doing this...I figured a second set of eyes might see something I'm not.

Re: Calculations Not Accurate on Large Numbers 06.06.2012 09:45

Hello,

It seems that you apply number format before a calc. Number format returns string not a float (number).

You can delete the following line:

$sum=number_format($sum,2);

All number format should be at the end.

Hope this helps. Regards,
Moonsoft Team
www.moonsoft.es

Re: Calculations Not Accurate on Large Numbers 06.06.2012 16:38

I knew it was something I overlooked...you guys are awesome!

Everything is working great now :)
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Our clients' feedback