Previous:Float Identifiers Main Index Next:Builtin Float Identifiers
Arithmetic expressions: Basic math expressions can be created from float literals, identifiers or functions using the following operators in this order of precedence...

expressions in parentheses first 

unary minus, unary plus and logical "not" 

multiplication and division 

addition and subtraction 
Relational, logical and conditional expressions may also be created. However there is a restriction that these types of expressions must be enclosed in parentheses first. This restriction, which is not imposed by most computer languages, is necessary because POVRay allows mixing of float and vector expressions. Without the parentheses there is an ambiguity problem. Parentheses are not required for the unary logical not operator "!" as shown above. The operators and their precedence are shown here.
Relational expressions: The operands are arithmetic expressions and the result is always boolean with 1 for true and 0 for false. All relational operators have the same precedence.

A is less than B 

A is less than or equal to B 

A is equal to B (actually abs(AB)<EPSILON) 

A is not equal to B (actually abs(AB)>=EPSILON) 

A is greater than or equal to B 

A is greater than B 
Logical expressions: The operands are converted to boolean values of 0 for false and 1 for true. The result is always boolean. All logical operators have the same precedence. Note that these are not bitwise operations, they are logical.

true only if both A and B are true, false otherwise 

true if either A or B or both are true 
Conditional expressions: The operand C is boolean while operands A and B are any expressions. The result is of the same type as A and B.

if C then A else B 
Assuming the various identifiers have been declared, the following are examples of valid expressions...
1+2+3 2*5 1/3 Row*3 Col*5 (Offset5)/2 This/That+Other*Thing ((This<That) & (Other>=Thing)?Foo:Bar)
Expressions are evaluated left to right with innermost parentheses evaluated first, then unary +,  or !, then multiply or divide, then add or subtract, then relational, then logical, then conditional.
Previous:Float Identifiers Main Index Next:Builtin Float Identifiers