Hi. I'm trying to multiply fractions. How can I take '1 1/2' and multiply it to get 3?
(is there some special format like '1-1/2' that I need to use to multiply it?)
Its much easier to use decimals, however you can use "fractions" by simple addition and division. For your example, 1 1/2 = 1+(1/2) although this can also be written 1+1/2 since division takes precedence.
Agree with darkagn.
BUT multiplication - be careful this will also take precedence (BODMAS, PODMAS, BIDMAS, PIDMAS - whatever you want to call it).
So place the term to be multiplied within brackets, otherwise you'll just multiply the integer or the fraction.
echo (1 + 1/2) * 2; //gives 3 echo 1 + 1/2 * 2; //gives 2 echo 2 * 1 + 1/2; //gives 2.5