From 341792016746eecd2fef255a4d4c62a8332f9b50 Mon Sep 17 00:00:00 2001 From: smurf3tte <75271109+smurf3tte@users.noreply.github.com> Date: Sat, 19 Dec 2020 12:49:19 -0800 Subject: [PATCH] Grow internal expr int representation to 64 bits This is necessary to retain precision above 32 bits, but more importantly to prevent an expression like (0x80000000 | 1) from flipping the sign of the result. --- Externals/expr/include/expr.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Externals/expr/include/expr.h b/Externals/expr/include/expr.h index c9475e4521..f531f378dd 100644 --- a/Externals/expr/include/expr.h +++ b/Externals/expr/include/expr.h @@ -14,6 +14,7 @@ extern "C" { #include /* for isspace */ #include #include /* for pow */ +#include #include #include #include @@ -288,13 +289,13 @@ static struct expr_var *expr_get_var(struct expr_var_list *vars, const char *s, return v; } -static int to_int(double x) { +static int64_t to_int(double x) { if (isnan(x)) { return 0; } else if (isinf(x) != 0) { - return INT_MAX * isinf(x); + return INT64_MAX * isinf(x); } else { - return (int)x; + return (int64_t)x; } }