I do not know if the title explains the doubt well, but I'll give you an example:
A product costs 50 cents each. I want customers to select the number of products they want to carry. So far so good.
If I multiply $ 0.50xNumberPar, the result is an integer.
However, if I multiply by an odd number, the result is a broken number.
My code:
if($mc_quantia == 1) {
//Se a quantia for 1, o preço será 50 centavos
$item = "R$0,50";
} else {
//Se não, pegue a quantia e divida por 2 (Porque cada 50 centavos é meio real, então eu preciso dividir por 2)
$id_4 = $mc_quantia/2;
$item = 'R$'.$id_4.',00';
}
The problem:
If the amount is 3, it will return $ 1.50.
I would like it to go straight back to $ 1.50
Can you help me?