aboutsummaryrefslogtreecommitdiff
path: root/src/exact_value.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-06-15 23:01:12 +0100
committergingerBill <bill@gingerbill.org>2018-06-15 23:01:12 +0100
commitba776a3c9fbaa8f64f1567112c71c93416776260 (patch)
tree094b956896d45cf2effc3045113c030120d9eaef /src/exact_value.cpp
parentcd7e260f4e77ea992115b3dd26d7b92d99bae0f7 (diff)
Fix bitwise not for signed integers
Diffstat (limited to 'src/exact_value.cpp')
-rw-r--r--src/exact_value.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/exact_value.cpp b/src/exact_value.cpp
index 1fe0206d8..1760d05c2 100644
--- a/src/exact_value.cpp
+++ b/src/exact_value.cpp
@@ -353,7 +353,7 @@ ExactValue exact_value_make_imag(ExactValue v) {
}
-ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision) {
+ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision, bool is_unsigned) {
switch (op) {
case Token_Add: {
switch (v.kind) {
@@ -404,7 +404,9 @@ ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision)
// NOTE(bill): unsigned integers will be negative and will need to be
// limited to the types precision
// IMPORTANT NOTE(bill): Max precision is 64 bits as that's how integers are stored
- i = i & unsigned_integer_maxs[precision/8];
+ if (is_unsigned) {
+ i = i & unsigned_integer_maxs[precision/8];
+ }
// if (0 < precision && precision < 64) {
// i = i & ~(-1ll << precision);
// }