0

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?)

Thanks

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by calebcook
0

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.

0

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.

e.g.

echo (1 + 1/2) * 2; //gives 3
echo 1 + 1/2 * 2; //gives 2
echo 2 * 1 + 1/2; //gives 2.5

Edited by diafol: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.