### Forum

## Calc Builder Support

Calc Builder supportForums

No se permite escribir sin estar logado. Por favor, 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.

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

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