# Android Questionrules of precedence

#### makeed0

##### New Member
What are the rules of precedence when dealing with built-in mathematical functions such as Sin, floor, and Ceil?

#### Brian Dean

##### Well-Known Member
Longtime User
Can you give an example where you think that an order of precedence for functions such as these is necessary? Rules of precedence are needed for something like the following, involving arithmetic operators, not functions . . .

A = X + Y * Z

You have to know the rules to realise that this (normally) means X + (Y * Z) rather that (X + Y) * Z. Note that the "rules of parentheses" are much less ambiguous - terms within parentheses are evaluated first and from inside to outside and left to right. Since the examples that you have given are all functions rather than operators, and so always require parentheses, then, it seems to me, that the rules of parentheses will always remove any ambiguity.

For instance . . .

sin(max(a, b))

. . . is not at all ambiguous. I am trying to think of a situation where this would not apply.

#### Daestrum

##### Expert
Longtime User
P.E.M.D.A.S.
Parenthesis - Exponent - Multiply - Divide - Add - Subtract from left to right

Replies
8
Views
4K
Replies
1
Views
1K
Android Question Get unique id for user
Replies
6
Views
5K
Replies
22
Views
3K
Replies
1
Views
753