Multiplying 2 decimal values resulting wrong number

124 Views Asked by At

I'm sure I'm missing something here. Take a look:

On my MySQL database, the 'value' field is a decimal, like this:

enter image description here

My database enconding is: utf8_general_ci.


My PHP code, to show the values:

$sale_limit_gen = Coo::getSaleLimitById(1);
$sale_limit_ale = Coo::getSaleLimitById(2);

echo $sale_limit_gen['value'];
echo '<br>';
echo $sale_limit_ale['value'];
echo '<br>';
echo $sale_limit_ale['value'] * $sale_limit_ale['value'];


But what I get is this:

enter image description here


Whats happening? The result should be 5.00, right?? What am I doing wrong?

1

There are 1 best solutions below

1
On BEST ANSWER

well multiplying 2.5 with 2.5 still results in 6.25 ;-) at least my calculator tells me that.

What you probably wanted to do was

echo $sale_limit_gen['value'] * $sale_limit_ale['value'];

instead of

echo $sale_limit_ale['value'] * $sale_limit_ale['value'];

so its a matter of a simple typo.