Skip to content

Arithmetic Operator

Let's see how Hongtu can do simple math calculation.

Add Node

Right-Click Anywhere on canvas, select Operator/Arithmetic

Connect Nodes

Let's do a little bit calculation with some nodes and connections:

TIP

Input will be hidden after connected

Cons & Pros

While text-based language can write code looks more like a math work, e.g. 5 * (3 + 2), it's very hard to see the intermediate results. A visual programming language like Hongtu can help us to see the intermediate results. Although the example above is too simple, however, when calculations gets more complex, the intermediate results will be more helpful.

Order of Operations

For statements with white handles, Hongtu executes from left to right. Before the execution of each node, Hongtu has to resolve its input values. This process is called Evaluation. Although evaluation starts from right to left, in effect, since the left ones are the input of the right ones, so in order to resolve values of the right ones, we always need to resolve the left ones first, recursively. So, the actual order of evaluation is also left to right. As for the example above, the Addition will be evaluate first, to resolve its value, we have to firstly evaluate the Multiplication nodes on the left. This is equivalent to the following code:

js
2 * 5 + 100 / 10