feat(Evaluator): add strict comparaison operators
This commit is contained in:
parent
35ca9c31ea
commit
b72448c62d
4 changed files with 25 additions and 2 deletions
|
|
@ -14,7 +14,9 @@ int is_operator(char candidate) {
|
|||
candidate == '=' ||
|
||||
candidate == '!' ||
|
||||
candidate == '&' ||
|
||||
candidate == '|'
|
||||
candidate == '|' ||
|
||||
candidate == '>' ||
|
||||
candidate == '<'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +85,10 @@ int operate(
|
|||
res = m_float_pow(a, b);
|
||||
} else if (operator == '=') {
|
||||
res = (int) (a == b);
|
||||
} else if (operator == '>') {
|
||||
res = (int) (a > b);
|
||||
} else if (operator == '<') {
|
||||
res = (int) (a < b);
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
|
|
@ -105,6 +111,10 @@ int operate(
|
|||
res = integer_pow(aRepr, bRepr);
|
||||
} else if (operator == '=') {
|
||||
res = (int) (aRepr == bRepr);
|
||||
} else if (operator == '<') {
|
||||
res = (int) (aRepr < bRepr);
|
||||
} else if (operator == '>') {
|
||||
res = (int) (aRepr > bRepr);
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue