Main About Download Schemes Documentation Resources

Operators

About

The notation used for comparisons logical operators, etc... vary greatly between different programming languages. Flowgorithm supports the symbols used in mathmetics (using Unicode values) as well as the two major families of programming languages. The "BASIC-family" contains English keywords and operators. The "C-family" (which includes C, Java, C#) is far more symbolic.

Since mathematics and two major language families are supported, there are redundant operators. Flowgorithm considers the redundant operates as the same - and any set can be used (or all of them). This allows the student to use the operators that match the language they plan to to learn later.

Operator C Family BASIC Family Mathematics (Unicode)
Equality == = =
Inequality != <>
Less Than or Equal <= <=
Greater Than Or Equal >= >=
Logical Not ! not ¬
Logical And && and
Logical Or || or
Multiply * * ×
Divide / / ÷
Modulo % mod  

Flowgorithm also adds a few unique Visual Basic operators since if they have helpful, clearly defined, semantics

Name Basic Family Mathematics (Unicode) Notes
String Concatenation &   C# and Java use the ambiguous "+" operator for addition and concatenation.
Exponent ^ Note: this is not a typical mathematical symbol, but is often used when superscripts cannot be used.

In Java and C#, the + operator is used for both string concatenation and addition. This can be quite confusing given the rather complex semantics. In Flowgorithm, addition will only work with numbers. The ampersand & is used for concatenation. Also, C# and Java lack an exponent operator - instead relying their respective Math classes. Flowgorithm uses the Visual Basic ^.

Precedence

The following are the precedence levels from high (evaluated first) to low.

Level Name Operators Notes
8 Unary -  !  not  ¬ In Visual Basic, "not" precedence level is far lower - above "and", but below all relational operators.
7 Exponent ^  ↑ The exponent operator does not exist in C# or Java.
6 Multiply *  ×  /  ÷  %  mod Division will always be high-precision (floating point)
5 Addition +  -  In Flowgorithm, "+" will only work with numbers.
4 Concatenate &  
3 Relational >  <  >=  ≥  <=  ≤  ==  =  !=  <>  ≠  
2 Logical And and  &&  ∧  
1 Logical Or or  ||  ∨  

Examples

Expression Result Notes
1 + 3 ^ 2 10  
10 * 2 + 5 * 6 50 10 * 2 and 5 * 6 have higher precedence than addition. The addition is done last.
7 * (4 - 1) 21 Parenthesis are used for subexpressions, which are evaluated as a whole.
6 / 3 * 2 4 In mathematics, multiplication and division have the same precedence levels. So, they are evaluated left-to-right. The "PEMDAS" acronym, used in high-school, is a tad misleading.
10 mod 3 1 Modulo math gives the remainder from division
10 % 3 1 Same expression, but using the C-Family operator