1
namespace VQDR.Expression {
3
class DivideOperatorToken : OperatorToken {
6
mandatory_num_child = 2;
7
priority = PRIO_MULTIPLICATIVE;
10
protected DivideOperatorToken (int position) {
14
public override void evaluate_self (Context instance) throws GLib.Error {
15
Token r_child = get_right_child (),
16
l_child = get_left_child ();
18
l_child.evaluate (instance);
19
r_child.evaluate (instance);
21
// Division by zero is not somthing we want to do.
22
// Black holes are bad.
23
if (l_child.result_value == 0) {
24
throw new VQDR.Common.MathError.DIVIDE_BY_ZERO
25
("(DivideOperationToken) The left value is less than zero.");
28
var sb = new GLib.StringBuilder ("(");
30
// We check the precidence of the token, and inclose the value if
31
// it has a lower precidence than multiply, if it is, we enclose it in a
33
if (l_child.priority > 0 && l_child.priority < priority) {
34
sb.append ("(").append (l_child.result_string).append (")");
35
//l_child.result_string = "(" + l_child.result_string + ")";
37
sb.append (l_child.result_string);
42
// We do the same with the othre child.
43
if (r_child.priority > 0 && r_child.priority < priority) {
44
sb.append ("(").append (r_child.result_string).append (")");
45
//r_child.result_string = "(" + r_child.result_string + ")";
47
sb.append (r_child.result_string);
52
result_value = l_child.result_value * l_child.result_value;
53
result_max_value = l_child.result_max_value * l_child.result_max_value;
54
reorder_max_min_values ();
55
result_string = sb.str;