equal
deleted
inserted
replaced
115 * For this reason, this visitor merely annotates the abstract syntax tree, and leaves the |
115 * For this reason, this visitor merely annotates the abstract syntax tree, and leaves the |
116 * actuall printing of errors for the print_datatype_errors_c class! |
116 * actuall printing of errors for the print_datatype_errors_c class! |
117 */ |
117 */ |
118 |
118 |
119 #include "constant_folding.hh" |
119 #include "constant_folding.hh" |
120 #include <limits> |
|
121 #include <math.h> /* required for pow function, and HUGE_VAL, HUGE_VALF, HUGE_VALL */ |
|
122 #include <stdlib.h> /* required for malloc() */ |
120 #include <stdlib.h> /* required for malloc() */ |
123 |
|
124 |
121 |
125 #include <string.h> /* required for strlen() */ |
122 #include <string.h> /* required for strlen() */ |
126 // #include <stdlib.h> /* required for atoi() */ |
123 // #include <stdlib.h> /* required for atoi() */ |
127 #include <errno.h> /* required for errno */ |
124 #include <errno.h> /* required for errno */ |
128 |
125 |
129 #include <../main.hh> /* required for UINT64_MAX, INT64_MAX, INT64_MIN, ... */ |
126 #include "../main.hh" // required for uint8_t, real_64_t, ..., and the macros NAN, INFINITY, INT8_MAX, REAL32_MAX, ... */ |
130 |
127 |
131 |
128 |
132 |
129 |
133 |
130 |
134 |
131 |
506 /* The IEC 61131-3 clearly states in section '2.5.1.5.2 Numerical functions': |
503 /* The IEC 61131-3 clearly states in section '2.5.1.5.2 Numerical functions': |
507 * "It is an error if the result of evaluation of one of these [numerical] functions exceeds the range of values |
504 * "It is an error if the result of evaluation of one of these [numerical] functions exceeds the range of values |
508 * specified for the data type of the function output, or if division by zero is attempted." |
505 * specified for the data type of the function output, or if division by zero is attempted." |
509 * For this reason, any operation that has as a result a positive or negative inifinity, is also an error! |
506 * For this reason, any operation that has as a result a positive or negative inifinity, is also an error! |
510 */ |
507 */ |
511 if ((isnan(res)) || (res == HUGE_VAL64) || (res == -HUGE_VAL64)) |
508 if ((isnan(res)) || (res == INFINITY) || (res == -INFINITY)) |
512 SET_OVFLOW(real64, res_ptr); |
509 SET_OVFLOW(real64, res_ptr); |
513 } |
510 } |
514 |
511 |
515 |
512 |
516 |
513 |